mirror of
https://github.com/wfjm/w11.git
synced 2026-04-29 13:23:22 +00:00
use mutex and friends from std:: instead from boost::
- use std::mutex - use std::recursive_mutex - use std::condition_variable - use std::lock_guard
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
// $Id: ReventLoop.cpp 1083 2018-12-15 19:19:16Z mueller $
|
||||
// $Id: ReventLoop.cpp 1085 2018-12-16 14:11:16Z mueller $
|
||||
//
|
||||
// Copyright 2013-2018 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
|
||||
//
|
||||
@@ -13,6 +13,7 @@
|
||||
//
|
||||
// Revision History:
|
||||
// Date Rev Version Comment
|
||||
// 2018-12-17 1085 1.2.4 use std::lock_guard instead of boost
|
||||
// 2018-12-15 1083 1.2.3 AddPollHandler(): use rval ref and move
|
||||
// 2018-11-09 1066 1.2.2 use emplace_back
|
||||
// 2017-04-07 868 1.2.1 Dump(): add detail arg
|
||||
@@ -33,7 +34,7 @@
|
||||
#include <poll.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "boost/thread/locks.hpp"
|
||||
#include <mutex>
|
||||
|
||||
#include "librtools/Rexception.hpp"
|
||||
#include "librtools/RosPrintf.hpp"
|
||||
@@ -80,7 +81,7 @@ ReventLoop::~ReventLoop()
|
||||
|
||||
void ReventLoop::AddPollHandler(pollhdl_t&& pollhdl, int fd, short events)
|
||||
{
|
||||
boost::lock_guard<boost::mutex> lock(fPollDscMutex);
|
||||
lock_guard<mutex> lock(fPollDscMutex);
|
||||
|
||||
for (size_t i=0; i<fPollDsc.size(); i++) {
|
||||
if (fPollDsc[i].fFd == fd &&
|
||||
@@ -106,7 +107,7 @@ void ReventLoop::AddPollHandler(pollhdl_t&& pollhdl, int fd, short events)
|
||||
|
||||
void ReventLoop::RemovePollHandler(int fd, short events, bool nothrow)
|
||||
{
|
||||
boost::lock_guard<boost::mutex> lock(fPollDscMutex);
|
||||
lock_guard<mutex> lock(fPollDscMutex);
|
||||
|
||||
for (size_t i=0; i<fPollDsc.size(); i++) {
|
||||
if (fPollDsc[i].fFd == fd &&
|
||||
@@ -129,7 +130,7 @@ void ReventLoop::RemovePollHandler(int fd, short events, bool nothrow)
|
||||
|
||||
bool ReventLoop::TestPollHandler(int fd, short events)
|
||||
{
|
||||
boost::lock_guard<boost::mutex> lock(fPollDscMutex);
|
||||
lock_guard<mutex> lock(fPollDscMutex);
|
||||
|
||||
for (size_t i=0; i<fPollDsc.size(); i++) {
|
||||
if (fPollDsc[i].fFd == fd &&
|
||||
@@ -145,7 +146,7 @@ bool ReventLoop::TestPollHandler(int fd, short events)
|
||||
|
||||
void ReventLoop::RemovePollHandler(int fd)
|
||||
{
|
||||
boost::lock_guard<boost::mutex> lock(fPollDscMutex);
|
||||
lock_guard<mutex> lock(fPollDscMutex);
|
||||
|
||||
for (size_t i=0; i<fPollDsc.size(); i++) {
|
||||
if (fPollDsc[i].fFd == fd) {
|
||||
@@ -192,7 +193,7 @@ void ReventLoop::Dump(std::ostream& os, int ind, const char* text,
|
||||
os << bl << " fStopPending: " << fStopPending << endl;
|
||||
os << bl << " fUpdatePoll: " << fUpdatePoll << endl;
|
||||
{
|
||||
boost::lock_guard<boost::mutex> lock(((ReventLoop*)this)->fPollDscMutex);
|
||||
lock_guard<mutex> lock(((ReventLoop*)this)->fPollDscMutex);
|
||||
os << bl << " fPollDsc.size: " << fPollDsc.size() << endl;
|
||||
os << bl << " fPollFd.size: " << fPollFd.size() << endl;
|
||||
os << bl << " fPollHdl.size: " << fPollHdl.size() << endl;
|
||||
@@ -216,7 +217,7 @@ void ReventLoop::Dump(std::ostream& os, int ind, const char* text,
|
||||
int ReventLoop::DoPoll(int timeout)
|
||||
{
|
||||
if (fUpdatePoll) {
|
||||
boost::lock_guard<boost::mutex> lock(fPollDscMutex);
|
||||
lock_guard<mutex> lock(fPollDscMutex);
|
||||
|
||||
fPollFd.resize(fPollDsc.size());
|
||||
fPollHdl.resize(fPollDsc.size());
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// $Id: ReventLoop.hpp 1084 2018-12-16 12:23:53Z mueller $
|
||||
// $Id: ReventLoop.hpp 1085 2018-12-16 14:11:16Z mueller $
|
||||
//
|
||||
// Copyright 2013-2018 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
|
||||
//
|
||||
@@ -13,6 +13,7 @@
|
||||
//
|
||||
// Revision History:
|
||||
// Date Rev Version Comment
|
||||
// 2018-12-17 1085 1.2.6 use std::mutex instead of boost
|
||||
// 2018-12-16 1084 1.2.5 use =delete for noncopyable instead of boost
|
||||
// 2018-12-15 1083 1.2.4 AddPollHandler(): use rval ref and move
|
||||
// 2018-12-14 1081 1.2.3 use std::function instead of boost
|
||||
@@ -39,8 +40,7 @@
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
#include <functional>
|
||||
|
||||
#include "boost/thread/mutex.hpp"
|
||||
#include <mutex>
|
||||
|
||||
#include "librtools/RlogFile.hpp"
|
||||
|
||||
@@ -91,7 +91,7 @@ namespace Retro {
|
||||
|
||||
bool fStopPending;
|
||||
bool fUpdatePoll;
|
||||
boost::mutex fPollDscMutex;
|
||||
std::mutex fPollDscMutex;
|
||||
std::vector<PollDsc> fPollDsc;
|
||||
std::vector<pollfd> fPollFd;
|
||||
std::vector<pollhdl_t> fPollHdl;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// $Id: RlinkConnect.cpp 1079 2018-12-09 10:56:59Z mueller $
|
||||
// $Id: RlinkConnect.cpp 1085 2018-12-16 14:11:16Z mueller $
|
||||
//
|
||||
// Copyright 2011-2018 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
|
||||
//
|
||||
@@ -13,6 +13,7 @@
|
||||
//
|
||||
// Revision History:
|
||||
// Date Rev Version Comment
|
||||
// 2018-12-17 1085 2.8.1 use std::lock_guard instead of boost
|
||||
// 2018-12-08 1079 2.8 add HasPort(); return ref for Port()
|
||||
// 2018-12-01 1076 2.7 use unique_ptr instead of scoped_ptr
|
||||
// 2018-11-30 1075 2.6.4 use list-init; use range loop
|
||||
@@ -50,8 +51,6 @@
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include "boost/thread/locks.hpp"
|
||||
|
||||
#include "RlinkPortFactory.hpp"
|
||||
#include "librtools/RosFill.hpp"
|
||||
#include "librtools/RosPrintf.hpp"
|
||||
@@ -350,7 +349,7 @@ bool RlinkConnect::Exec(RlinkCommandList& clist, RlinkContext& cntx,
|
||||
if (! IsOpen())
|
||||
throw Rexception("RlinkConnect::Exec()", "Bad state: port not open");
|
||||
|
||||
boost::lock_guard<RlinkConnect> lock(*this);
|
||||
lock_guard<RlinkConnect> lock(*this);
|
||||
|
||||
fStats.Inc(kStatNExec);
|
||||
|
||||
@@ -496,7 +495,7 @@ int RlinkConnect::WaitAttn(const Rtime& timeout, Rtime& twait,
|
||||
apat = 0;
|
||||
twait.Clear();
|
||||
|
||||
boost::lock_guard<RlinkConnect> lock(*this);
|
||||
lock_guard<RlinkConnect> lock(*this);
|
||||
|
||||
// harvest pending notifiers
|
||||
if (fAttnNotiPatt != 0) {
|
||||
@@ -546,7 +545,7 @@ int RlinkConnect::WaitAttn(const Rtime& timeout, Rtime& twait,
|
||||
|
||||
bool RlinkConnect::SndOob(uint16_t addr, uint16_t data, RerrMsg& emsg)
|
||||
{
|
||||
boost::lock_guard<RlinkConnect> lock(*this);
|
||||
lock_guard<RlinkConnect> lock(*this);
|
||||
fStats.Inc(kStatNSndOob);
|
||||
return fSndPkt.SndOob(Port(), addr, data, emsg);
|
||||
}
|
||||
@@ -556,7 +555,7 @@ bool RlinkConnect::SndOob(uint16_t addr, uint16_t data, RerrMsg& emsg)
|
||||
|
||||
bool RlinkConnect::SndAttn(RerrMsg& emsg)
|
||||
{
|
||||
boost::lock_guard<RlinkConnect> lock(*this);
|
||||
lock_guard<RlinkConnect> lock(*this);
|
||||
return fSndPkt.SndAttn(Port(), emsg);
|
||||
}
|
||||
|
||||
@@ -739,7 +738,7 @@ void RlinkConnect::HandleUnsolicitedData()
|
||||
throw Rexception("RlinkConnect::HandleUnsolicitedData()",
|
||||
"only allowed inside active server");
|
||||
|
||||
boost::lock_guard<RlinkConnect> lock(*this);
|
||||
lock_guard<RlinkConnect> lock(*this);
|
||||
RerrMsg emsg;
|
||||
int irc = fRcvPkt.ReadData(Port(), Rtime(), emsg);
|
||||
if (irc == 0) return;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// $Id: RlinkConnect.hpp 1084 2018-12-16 12:23:53Z mueller $
|
||||
// $Id: RlinkConnect.hpp 1088 2018-12-17 17:37:00Z mueller $
|
||||
//
|
||||
// Copyright 2011-2018 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
|
||||
//
|
||||
@@ -13,6 +13,7 @@
|
||||
//
|
||||
// Revision History:
|
||||
// Date Rev Version Comment
|
||||
// 2018-12-17 1085 2.8.2 use std::recursive_mutex instead of boost
|
||||
// 2018-12-16 1084 2.8.1 use =delete for noncopyable instead of boost
|
||||
// 2018-12-08 1079 2.8 add HasPort(); return ref for Port()
|
||||
// 2018-12-07 1078 2.7.1 use std::shared_ptr instead of boost
|
||||
@@ -58,8 +59,7 @@
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
#include <ostream>
|
||||
|
||||
#include "boost/thread/recursive_mutex.hpp"
|
||||
#include <mutex>
|
||||
|
||||
#include "librtools/RerrMsg.hpp"
|
||||
#include "librtools/Rtime.hpp"
|
||||
@@ -106,7 +106,7 @@ namespace Retro {
|
||||
bool ServerActiveInside() const;
|
||||
bool ServerActiveOutside() const;
|
||||
|
||||
// provide boost Lockable interface
|
||||
// provide Lockable interface
|
||||
void lock();
|
||||
bool try_lock();
|
||||
void unlock();
|
||||
@@ -260,7 +260,7 @@ namespace Retro {
|
||||
uint32_t fTraceLevel; //!< trace 0=off,1=buf,2=char
|
||||
Rtime fTimeout; //!< response timeout
|
||||
std::shared_ptr<RlogFile> fspLog; //!< log file ptr
|
||||
boost::recursive_mutex fConnectMutex; //!< mutex to lock whole connect
|
||||
std::recursive_mutex fConnectMutex; //!< mutex to lock whole connect
|
||||
uint16_t fAttnNotiPatt; //!< attn notifier pattern
|
||||
Rtime fTsLastAttnNoti; //!< time stamp last attn notify
|
||||
uint32_t fSysId; //!< SYSID of connected device
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// $Id: RlinkPortFifo.cpp 1075 2018-12-01 11:55:07Z mueller $
|
||||
// $Id: RlinkPortFifo.cpp 1085 2018-12-16 14:11:16Z mueller $
|
||||
//
|
||||
// Copyright 2011-2018 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
|
||||
//
|
||||
@@ -29,6 +29,7 @@
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "RlinkPortFifo.hpp"
|
||||
|
||||
@@ -75,7 +76,7 @@ bool RlinkPortFifo::Open(const std::string& url, RerrMsg& emsg)
|
||||
|
||||
fFdRead = OpenFifo(fUrl.Path() + "_tx", false, emsg);
|
||||
if (fFdRead < 0) {
|
||||
close(fFdWrite);
|
||||
::close(fFdWrite);
|
||||
fFdWrite = -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// $Id: RlinkServer.cpp 1083 2018-12-15 19:19:16Z mueller $
|
||||
// $Id: RlinkServer.cpp 1085 2018-12-16 14:11:16Z mueller $
|
||||
//
|
||||
// Copyright 2013-2018 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
|
||||
//
|
||||
@@ -13,6 +13,7 @@
|
||||
//
|
||||
// Revision History:
|
||||
// Date Rev Version Comment
|
||||
// 2018-12-17 1085 1.2.8 use std::lock_guard instead of boost
|
||||
// 2018-12-15 1083 2.2.7 for std::function setups: use rval ref and move
|
||||
// 2018-12-14 1081 2.2.6 use std::bind instead of boost
|
||||
// 2018-12-07 1078 2.2.5 use std::shared_ptr instead of boost
|
||||
@@ -35,8 +36,6 @@
|
||||
\brief Implemenation of RlinkServer.
|
||||
*/
|
||||
|
||||
#include "boost/thread/locks.hpp"
|
||||
|
||||
#include "librtools/Rexception.hpp"
|
||||
#include "librtools/RosFill.hpp"
|
||||
#include "librtools/RosPrintf.hpp"
|
||||
@@ -143,7 +142,7 @@ void RlinkServer::AddAttnHandler(attnhdl_t&& attnhdl, uint16_t mask,
|
||||
if (mask == 0)
|
||||
throw Rexception("RlinkServer::AddAttnHandler()", "Bad args: mask == 0");
|
||||
|
||||
boost::lock_guard<RlinkConnect> lock(*fspConn);
|
||||
lock_guard<RlinkConnect> lock(*fspConn);
|
||||
|
||||
AttnId id(mask, cdata);
|
||||
for (size_t i=0; i<fAttnDsc.size(); i++) {
|
||||
@@ -190,7 +189,7 @@ void RlinkServer::GetAttnInfo(AttnArgs& args)
|
||||
|
||||
void RlinkServer::RemoveAttnHandler(uint16_t mask, void* cdata)
|
||||
{
|
||||
boost::lock_guard<RlinkConnect> lock(*fspConn);
|
||||
lock_guard<RlinkConnect> lock(*fspConn);
|
||||
|
||||
AttnId id(mask, cdata);
|
||||
for (size_t i=0; i<fAttnDsc.size(); i++) {
|
||||
@@ -209,7 +208,7 @@ void RlinkServer::RemoveAttnHandler(uint16_t mask, void* cdata)
|
||||
|
||||
void RlinkServer::QueueAction(actnhdl_t&& actnhdl)
|
||||
{
|
||||
boost::lock_guard<RlinkConnect> lock(*fspConn);
|
||||
lock_guard<RlinkConnect> lock(*fspConn);
|
||||
fActnList.push_back(move(actnhdl));
|
||||
if (IsActiveOutside()) Wakeup();
|
||||
return;
|
||||
@@ -220,7 +219,7 @@ void RlinkServer::QueueAction(actnhdl_t&& actnhdl)
|
||||
|
||||
void RlinkServer::AddPollHandler(pollhdl_t&& pollhdl, int fd, short events)
|
||||
{
|
||||
boost::lock_guard<RlinkConnect> lock(*fspConn);
|
||||
lock_guard<RlinkConnect> lock(*fspConn);
|
||||
fELoop.AddPollHandler(move(pollhdl), fd, events);
|
||||
if (IsActiveOutside()) Wakeup();
|
||||
return;
|
||||
@@ -231,7 +230,7 @@ void RlinkServer::AddPollHandler(pollhdl_t&& pollhdl, int fd, short events)
|
||||
|
||||
bool RlinkServer::TestPollHandler(int fd, short events)
|
||||
{
|
||||
boost::lock_guard<RlinkConnect> lock(*fspConn);
|
||||
lock_guard<RlinkConnect> lock(*fspConn);
|
||||
return fELoop.TestPollHandler(fd, events);
|
||||
}
|
||||
|
||||
@@ -240,7 +239,7 @@ bool RlinkServer::TestPollHandler(int fd, short events)
|
||||
|
||||
void RlinkServer::RemovePollHandler(int fd, short events, bool nothrow)
|
||||
{
|
||||
boost::lock_guard<RlinkConnect> lock(*fspConn);
|
||||
lock_guard<RlinkConnect> lock(*fspConn);
|
||||
fELoop.RemovePollHandler(fd, events,nothrow);
|
||||
if (IsActiveOutside()) Wakeup();
|
||||
return;
|
||||
@@ -251,7 +250,7 @@ void RlinkServer::RemovePollHandler(int fd, short events, bool nothrow)
|
||||
|
||||
void RlinkServer::RemovePollHandler(int fd)
|
||||
{
|
||||
boost::lock_guard<RlinkConnect> lock(*fspConn);
|
||||
lock_guard<RlinkConnect> lock(*fspConn);
|
||||
fELoop.RemovePollHandler(fd);
|
||||
if (IsActiveOutside()) Wakeup();
|
||||
return;
|
||||
@@ -406,7 +405,7 @@ void RlinkServer::StartOrResume(bool resume)
|
||||
throw Rexception("RlinkServer::StartOrResume()",
|
||||
"Bad state: RlinkConnect not open");
|
||||
|
||||
boost::lock_guard<RlinkConnect> lock(Connect());
|
||||
lock_guard<RlinkConnect> lock(Connect());
|
||||
// enable attn notify send
|
||||
RlinkCommandList clist;
|
||||
if (!resume) clist.AddAttn();
|
||||
@@ -449,7 +448,7 @@ void RlinkServer::CallAttnHandler()
|
||||
|
||||
// if notifier pending, transfer it to current attn pattern
|
||||
if (fAttnNotiPatt) {
|
||||
boost::lock_guard<RlinkConnect> lock(*fspConn);
|
||||
lock_guard<RlinkConnect> lock(*fspConn);
|
||||
fStats.Inc(kStatNAttnNoti);
|
||||
if (fTraceLevel>0) {
|
||||
RlogMsg lmsg(LogFile());
|
||||
@@ -472,7 +471,7 @@ void RlinkServer::CallAttnHandler()
|
||||
uint16_t hmatch = fAttnPatt & fAttnDsc[i].fId.fMask;
|
||||
if (hmatch) {
|
||||
AttnArgs args(fAttnPatt, fAttnDsc[i].fId.fMask);
|
||||
boost::lock_guard<RlinkConnect> lock(*fspConn);
|
||||
lock_guard<RlinkConnect> lock(*fspConn);
|
||||
|
||||
if (fTraceLevel>0) {
|
||||
RlogMsg lmsg(LogFile());
|
||||
@@ -533,7 +532,7 @@ void RlinkServer::CallActnHandler()
|
||||
if (!ActnPending()) return;
|
||||
|
||||
// call first action
|
||||
boost::lock_guard<RlinkConnect> lock(*fspConn);
|
||||
lock_guard<RlinkConnect> lock(*fspConn);
|
||||
|
||||
int irc = fActnList.front()();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user