From dcaf39ff8471a74bb2f9749af17f1f575cf5708d Mon Sep 17 00:00:00 2001 From: wfjm Date: Tue, 18 Dec 2018 10:22:35 +0100 Subject: [PATCH] use mutex and friends from std:: instead from boost:: - use std::mutex - use std::recursive_mutex - use std::condition_variable - use std::lock_guard --- doc/CHANGELOG.md | 5 ++++ tools/src/librlink/ReventLoop.cpp | 17 ++++++------ tools/src/librlink/ReventLoop.hpp | 8 +++--- tools/src/librlink/RlinkConnect.cpp | 15 +++++------ tools/src/librlink/RlinkConnect.hpp | 10 +++---- tools/src/librlink/RlinkPortFifo.cpp | 5 ++-- tools/src/librlink/RlinkServer.cpp | 27 +++++++++---------- tools/src/librlinktpp/RtclRlinkConnect.cpp | 9 +++---- tools/src/librlinktpp/RtclRlinkServer.cpp | 7 ++--- tools/src/librtools/RlogFile.cpp | 11 ++++---- tools/src/librtools/RlogFile.hpp | 10 +++---- tools/src/librtools/RlogMsg.cpp | 4 +-- tools/src/librw11/Rw11CntlDEUNA.cpp | 7 ++--- tools/src/librw11/Rw11Cpu.cpp | 25 ++++++++--------- tools/src/librw11/Rw11Cpu.hpp | 12 ++++----- tools/src/librw11/Rw11UnitTerm.cpp | 9 +++---- tools/src/librw11/Rw11UnitVirt.ipp | 9 +++---- tools/src/librwxxtpp/RtclRw11.cpp | 7 ++--- tools/src/librwxxtpp/RtclRw11Cntl.cpp | 9 +++---- tools/src/librwxxtpp/RtclRw11Cpu.cpp | 11 ++++---- tools/src/librwxxtpp/RtclRw11Unit.cpp | 15 +++++------ tools/src/librwxxtpp/RtclRw11Virt.cpp | 7 ++--- tools/src/librwxxtpp/RtclRw11VirtDiskOver.cpp | 7 ++--- tools/src/librwxxtpp/RtclRw11VirtDiskRam.cpp | 5 ++-- 24 files changed, 126 insertions(+), 125 deletions(-) diff --git a/doc/CHANGELOG.md b/doc/CHANGELOG.md index 996158ee..46b39c43 100644 --- a/doc/CHANGELOG.md +++ b/doc/CHANGELOG.md @@ -107,6 +107,11 @@ The full set of tests is only run for tagged releases. - use std::shared_ptr instead of boost - use std::function instead of boost - use std::bind or in most cases a lambda instead of boost::bind + - use mutex and friends from std:: instead from boost:: + - use std::mutex + - use std::recursive_mutex + - use std::condition_variable + - use std::lock_guard - use =delete for noncopyable instead of boost - reduce usage of pointers in APIs - add HasPort/HasVirt(); Port() and Virt() return reference diff --git a/tools/src/librlink/ReventLoop.cpp b/tools/src/librlink/ReventLoop.cpp index 5ba16d25..c5827409 100644 --- a/tools/src/librlink/ReventLoop.cpp +++ b/tools/src/librlink/ReventLoop.cpp @@ -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 // @@ -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 #include -#include "boost/thread/locks.hpp" +#include #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 lock(fPollDscMutex); + lock_guard lock(fPollDscMutex); for (size_t i=0; i lock(fPollDscMutex); + lock_guard lock(fPollDscMutex); for (size_t i=0; i lock(fPollDscMutex); + lock_guard lock(fPollDscMutex); for (size_t i=0; i lock(fPollDscMutex); + lock_guard lock(fPollDscMutex); for (size_t i=0; i lock(((ReventLoop*)this)->fPollDscMutex); + lock_guard 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 lock(fPollDscMutex); + lock_guard lock(fPollDscMutex); fPollFd.resize(fPollDsc.size()); fPollHdl.resize(fPollDsc.size()); diff --git a/tools/src/librlink/ReventLoop.hpp b/tools/src/librlink/ReventLoop.hpp index 72d392d5..645a2cdc 100644 --- a/tools/src/librlink/ReventLoop.hpp +++ b/tools/src/librlink/ReventLoop.hpp @@ -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 // @@ -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 #include #include - -#include "boost/thread/mutex.hpp" +#include #include "librtools/RlogFile.hpp" @@ -91,7 +91,7 @@ namespace Retro { bool fStopPending; bool fUpdatePoll; - boost::mutex fPollDscMutex; + std::mutex fPollDscMutex; std::vector fPollDsc; std::vector fPollFd; std::vector fPollHdl; diff --git a/tools/src/librlink/RlinkConnect.cpp b/tools/src/librlink/RlinkConnect.cpp index 233d9d8f..261fd3c4 100644 --- a/tools/src/librlink/RlinkConnect.cpp +++ b/tools/src/librlink/RlinkConnect.cpp @@ -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 // @@ -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 -#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 lock(*this); + lock_guard lock(*this); fStats.Inc(kStatNExec); @@ -496,7 +495,7 @@ int RlinkConnect::WaitAttn(const Rtime& timeout, Rtime& twait, apat = 0; twait.Clear(); - boost::lock_guard lock(*this); + lock_guard 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 lock(*this); + lock_guard 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 lock(*this); + lock_guard 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 lock(*this); + lock_guard lock(*this); RerrMsg emsg; int irc = fRcvPkt.ReadData(Port(), Rtime(), emsg); if (irc == 0) return; diff --git a/tools/src/librlink/RlinkConnect.hpp b/tools/src/librlink/RlinkConnect.hpp index b8cadccb..97a54280 100644 --- a/tools/src/librlink/RlinkConnect.hpp +++ b/tools/src/librlink/RlinkConnect.hpp @@ -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 // @@ -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 #include #include - -#include "boost/thread/recursive_mutex.hpp" +#include #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 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 diff --git a/tools/src/librlink/RlinkPortFifo.cpp b/tools/src/librlink/RlinkPortFifo.cpp index 3ddb15f3..11e16cc8 100644 --- a/tools/src/librlink/RlinkPortFifo.cpp +++ b/tools/src/librlink/RlinkPortFifo.cpp @@ -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 // @@ -29,6 +29,7 @@ #include #include #include +#include #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; } diff --git a/tools/src/librlink/RlinkServer.cpp b/tools/src/librlink/RlinkServer.cpp index 04405e13..354f9e97 100644 --- a/tools/src/librlink/RlinkServer.cpp +++ b/tools/src/librlink/RlinkServer.cpp @@ -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 // @@ -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 lock(*fspConn); + lock_guard lock(*fspConn); AttnId id(mask, cdata); for (size_t i=0; i lock(*fspConn); + lock_guard lock(*fspConn); AttnId id(mask, cdata); for (size_t i=0; i lock(*fspConn); + lock_guard 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 lock(*fspConn); + lock_guard 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 lock(*fspConn); + lock_guard 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 lock(*fspConn); + lock_guard 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 lock(*fspConn); + lock_guard 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 lock(Connect()); + lock_guard 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 lock(*fspConn); + lock_guard 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 lock(*fspConn); + lock_guard lock(*fspConn); if (fTraceLevel>0) { RlogMsg lmsg(LogFile()); @@ -533,7 +532,7 @@ void RlinkServer::CallActnHandler() if (!ActnPending()) return; // call first action - boost::lock_guard lock(*fspConn); + lock_guard lock(*fspConn); int irc = fActnList.front()(); diff --git a/tools/src/librlinktpp/RtclRlinkConnect.cpp b/tools/src/librlinktpp/RtclRlinkConnect.cpp index 5e9c1efe..660247a5 100644 --- a/tools/src/librlinktpp/RtclRlinkConnect.cpp +++ b/tools/src/librlinktpp/RtclRlinkConnect.cpp @@ -1,4 +1,4 @@ -// $Id: RtclRlinkConnect.cpp 1083 2018-12-15 19:19:16Z mueller $ +// $Id: RtclRlinkConnect.cpp 1085 2018-12-16 14:11:16Z mueller $ // // Copyright 2011-2018 by Walter F.J. Mueller // @@ -13,6 +13,7 @@ // // Revision History: // Date Rev Version Comment +// 2018-12-17 1085 1.6.6 use std::lock_guard instead of boost // 2018-12-15 1082 1.6.5 use lambda instead of bind // 2018-12-08 1079 1.6.4 use HasPort(); Port() returns now ref // 2018-12-07 1077 1.6.3 use SetLastExpectBlock move semantics @@ -56,8 +57,6 @@ #include -#include "boost/thread/locks.hpp" - #include "librtcltools/Rtcl.hpp" #include "librtcltools/RtclOPtr.hpp" #include "librtcltools/RtclNameSet.hpp" @@ -781,7 +780,7 @@ int RtclRlinkConnect::M_dump(RtclArgs& args) int RtclRlinkConnect::M_get(RtclArgs& args) { // synchronize with server thread (really needed ??) - boost::lock_guard lock(Obj()); + lock_guard lock(Obj()); return fGets.M_get(args); } @@ -791,7 +790,7 @@ int RtclRlinkConnect::M_get(RtclArgs& args) int RtclRlinkConnect::M_set(RtclArgs& args) { // synchronize with server thread (really needed ??) - boost::lock_guard lock(Obj()); + lock_guard lock(Obj()); return fSets.M_set(args); } diff --git a/tools/src/librlinktpp/RtclRlinkServer.cpp b/tools/src/librlinktpp/RtclRlinkServer.cpp index 91b1f1dc..9f507bfb 100644 --- a/tools/src/librlinktpp/RtclRlinkServer.cpp +++ b/tools/src/librlinktpp/RtclRlinkServer.cpp @@ -1,4 +1,4 @@ -// $Id: RtclRlinkServer.cpp 1082 2018-12-15 13:56:20Z mueller $ +// $Id: RtclRlinkServer.cpp 1087 2018-12-17 08:25:37Z mueller $ // // Copyright 2013-2018 by Walter F.J. Mueller // @@ -13,6 +13,7 @@ // // Revision History: // Date Rev Version Comment +// 2018-12-17 1087 1.2.2 use std::lock_guard instead of boost // 2018-12-14 1081 1.2.1 use std::bind instead of boost // 2018-12-01 1076 1.2 use unique_ptr // 2018-11-16 1070 1.1.2 use auto; use range loop @@ -304,7 +305,7 @@ int RtclRlinkServer::M_dump(RtclArgs& args) int RtclRlinkServer::M_get(RtclArgs& args) { // synchronize with server thread (really needed ??) - boost::lock_guard lock(Obj().Connect()); + lock_guard lock(Obj().Connect()); return fGets.M_get(args); } @@ -314,7 +315,7 @@ int RtclRlinkServer::M_get(RtclArgs& args) int RtclRlinkServer::M_set(RtclArgs& args) { // synchronize with server thread (really needed ??) - boost::lock_guard lock(Obj().Connect()); + lock_guard lock(Obj().Connect()); return fSets.M_set(args); } diff --git a/tools/src/librtools/RlogFile.cpp b/tools/src/librtools/RlogFile.cpp index 83042ca1..c1ec5cdd 100644 --- a/tools/src/librtools/RlogFile.cpp +++ b/tools/src/librtools/RlogFile.cpp @@ -1,6 +1,6 @@ -// $Id: RlogFile.cpp 983 2018-01-02 20:35:59Z mueller $ +// $Id: RlogFile.cpp 1085 2018-12-16 14:11:16Z mueller $ // -// Copyright 2011-2017 by Walter F.J. Mueller +// Copyright 2011-2018 by Walter F.J. Mueller // // This program is free software; you may redistribute and/or modify it under // the terms of the GNU General Public License as published by the Free @@ -13,6 +13,7 @@ // // Revision History: // Date Rev Version Comment +// 2018-12-17 1085 1.2.2 use std::lock_guard instead of boost // 2017-03-04 858 2.2.1 use clock_gettime instead of gettimeofday // 2015-01-08 631 2.2 Open(): now with RerrMsg and cout/cerr support // 2014-12-10 611 2.1.2 timestamp now usec precision (was msec) @@ -30,8 +31,8 @@ #include #include -#include "boost/thread/locks.hpp" - +#include + #include "RosFill.hpp" #include "RosPrintf.hpp" #include "RlogMsg.hpp" @@ -133,7 +134,7 @@ void RlogFile::Write(const std::string& str, char tag) { ostream& os = fpExtStream ? *fpExtStream : fIntStream; - boost::lock_guard lock(*this); + lock_guard lock(*this); if (tag) { struct timespec ts; diff --git a/tools/src/librtools/RlogFile.hpp b/tools/src/librtools/RlogFile.hpp index ba509f5b..32c49fce 100644 --- a/tools/src/librtools/RlogFile.hpp +++ b/tools/src/librtools/RlogFile.hpp @@ -1,4 +1,4 @@ -// $Id: RlogFile.hpp 1084 2018-12-16 12:23:53Z mueller $ +// $Id: RlogFile.hpp 1088 2018-12-17 17:37:00Z mueller $ // // Copyright 2011-2018 by Walter F.J. Mueller // @@ -13,6 +13,7 @@ // // Revision History: // Date Rev Version Comment +// 2018-12-17 1085 1.2.2 use std::mutex instead of boost // 2018-12-16 1084 2.2.1 use =delete for noncopyable instead of boost // 2015-01-08 631 2.2 Open(): now with RerrMsg and cout/cerr support // 2013-02-23 492 2.1 add Name(), keep log file name; add Dump() @@ -32,8 +33,7 @@ #include #include #include - -#include "boost/thread/mutex.hpp" +#include #include "RerrMsg.hpp" @@ -60,7 +60,7 @@ namespace Retro { void Dump(std::ostream& os, int ind=0, const char* text=0) const; - // provide boost Lockable interface + // provide Lockable interface void lock(); void unlock(); @@ -79,7 +79,7 @@ namespace Retro { int fTagYear; //!< year of last time tag int fTagMonth; //!< month of last time tag int fTagDay; //!< day of last time tag - boost::mutex fMutex; //!< mutex to lock file + std::mutex fMutex; //!< mutex to lock file }; } // end namespace Retro diff --git a/tools/src/librtools/RlogMsg.cpp b/tools/src/librtools/RlogMsg.cpp index 9fffd3b5..ceeaf15e 100644 --- a/tools/src/librtools/RlogMsg.cpp +++ b/tools/src/librtools/RlogMsg.cpp @@ -1,4 +1,4 @@ -// $Id: RlogMsg.cpp 983 2018-01-02 20:35:59Z mueller $ +// $Id: RlogMsg.cpp 1085 2018-12-16 14:11:16Z mueller $ // // Copyright 2013- by Walter F.J. Mueller // @@ -21,8 +21,6 @@ \brief Implemenation of RlogMsg. */ -#include "boost/thread/locks.hpp" - #include "RlogFile.hpp" #include "RlogMsg.hpp" diff --git a/tools/src/librw11/Rw11CntlDEUNA.cpp b/tools/src/librw11/Rw11CntlDEUNA.cpp index b5525d38..05666bfc 100644 --- a/tools/src/librw11/Rw11CntlDEUNA.cpp +++ b/tools/src/librw11/Rw11CntlDEUNA.cpp @@ -1,4 +1,4 @@ -// $Id: Rw11CntlDEUNA.cpp 1082 2018-12-15 13:56:20Z mueller $ +// $Id: Rw11CntlDEUNA.cpp 1087 2018-12-17 08:25:37Z mueller $ // // Copyright 2014-2018 by Walter F.J. Mueller // @@ -13,6 +13,7 @@ // // Revision History: // Date Rev Version Comment +// 2018-12-17 1087 0.5.6 use std::lock_guard instead of boost // 2018-12-15 1082 0.5.5 use lambda instead of bind // 2018-12-09 1080 0.5.4 use HasVirt(); Virt() returns ref // 2018-12-08 1078 0.5.3 BUGFIX: Start(Tx|Rx)Ring, was broken in r1049 @@ -534,7 +535,7 @@ const char* Rw11CntlDEUNA::MnemoState(uint16_t state) const bool Rw11CntlDEUNA::RcvCallback(RethBuf::pbuf_t& pbuf) { // lock connect to protect rxqueue - boost::lock_guard lock(Connect()); + lock_guard lock(Connect()); fStats.Inc(kStatNRxFraSeen); if (!Running()) { // drop if not running @@ -594,7 +595,7 @@ void Rw11CntlDEUNA::Dump(std::ostream& os, int ind, const char* text, int detail) const { // lock connect to protect, e.g fRxBufQueue access - boost::lock_guard lock(Connect()); + lock_guard lock(Connect()); RosFill bl(ind); os << bl << (text?text:"--") << "Rw11CntlDEUNA @ " << this << endl; diff --git a/tools/src/librw11/Rw11Cpu.cpp b/tools/src/librw11/Rw11Cpu.cpp index 0bb7b5fc..3863f651 100644 --- a/tools/src/librw11/Rw11Cpu.cpp +++ b/tools/src/librw11/Rw11Cpu.cpp @@ -1,4 +1,4 @@ -// $Id: Rw11Cpu.cpp 1078 2018-12-08 14:19:03Z mueller $ +// $Id: Rw11Cpu.cpp 1085 2018-12-16 14:11:16Z mueller $ // // Copyright 2013-2018 by Walter F.J. Mueller // @@ -13,6 +13,7 @@ // // Revision History: // Date Rev Version Comment +// 2018-12-17 1085 1.2.17 use std::mutex,condition_variable instead of boost // 2018-12-07 1078 1.2.16 use std::shared_ptr instead of boost // 2018-11-16 1070 1.2.15 use auto; use emplace,make_pair; use range loop // 2018-09-23 1050 1.2.14 add HasPcnt() @@ -51,8 +52,7 @@ #include #include #include - -#include "boost/date_time/posix_time/posix_time_types.hpp" +#include #include "librtools/Rexception.hpp" #include "librtools/RlogMsg.hpp" @@ -769,7 +769,7 @@ bool Rw11Cpu::Boot(const std::string& uname, RerrMsg& emsg) void Rw11Cpu::SetCpuActUp() { - boost::lock_guard lock(fCpuActMutex); + lock_guard lock(fCpuActMutex); fCpuAct = true; fCpuStat = 0; fCpuActCond.notify_all(); @@ -782,7 +782,7 @@ void Rw11Cpu::SetCpuActUp() void Rw11Cpu::SetCpuActDown(uint16_t stat) { if ((stat & kCPSTAT_M_CpuGo) == 0 || (stat & kCPSTAT_M_CpuSusp) != 0 ) { - boost::lock_guard lock(fCpuActMutex); + lock_guard lock(fCpuActMutex); fCpuAct = false; fCpuStat = stat; fCpuActCond.notify_all(); @@ -797,17 +797,14 @@ int Rw11Cpu::WaitCpuActDown(const Rtime& tout, Rtime& twait) { Rtime tstart(CLOCK_MONOTONIC); twait.Clear(); + + chrono::duration timeout(chrono::duration::max()); + if (tout.IsPositive()) + timeout = chrono::duration(tout.ToDouble()); - boost::system_time timeout(boost::posix_time::max_date_time); - if (tout.IsPositive()) - // Note: boost::posix_time might lack the nanoseconds ctor (if build with - // microsecond precision), thus use microsecond. - timeout = boost::get_system_time() + - boost::posix_time::seconds(tout.Sec()) + - boost::posix_time::microseconds(tout.NSec()/1000); - boost::unique_lock lock(fCpuActMutex); + unique_lock lock(fCpuActMutex); while (fCpuAct) { - if (!fCpuActCond.timed_wait(lock, timeout)) return -1; + if (fCpuActCond.wait_for(lock, timeout) == cv_status::timeout) return -1; } twait = Rtime(CLOCK_MONOTONIC) - tstart; return twait.IsPositive(); diff --git a/tools/src/librw11/Rw11Cpu.hpp b/tools/src/librw11/Rw11Cpu.hpp index 54f774df..3fa18466 100644 --- a/tools/src/librw11/Rw11Cpu.hpp +++ b/tools/src/librw11/Rw11Cpu.hpp @@ -1,4 +1,4 @@ -// $Id: Rw11Cpu.hpp 1084 2018-12-16 12:23:53Z mueller $ +// $Id: Rw11Cpu.hpp 1085 2018-12-16 14:11:16Z mueller $ // // Copyright 2013-2018 by Walter F.J. Mueller // @@ -13,6 +13,7 @@ // // Revision History: // Date Rev Version Comment +// 2018-12-17 1085 1.2.14 use std::mutex,condition_variable instead of boost // 2018-12-16 1084 1.2.13 use =delete for noncopyable instead of boost // 2018-12-07 1078 1.2.12 use std::shared_ptr instead of boost // 2018-09-23 1050 1.2.11 add HasPcnt() @@ -47,9 +48,8 @@ #include #include #include - -#include "boost/thread/locks.hpp" -#include "boost/thread/condition_variable.hpp" +#include +#include #include "librtools/Rstats.hpp" #include "librtools/RerrMsg.hpp" @@ -297,8 +297,8 @@ namespace Retro { bool fHasIist; //!< has iist (smp comm) bool fCpuAct; uint16_t fCpuStat; - boost::mutex fCpuActMutex; - boost::condition_variable fCpuActCond; + std::mutex fCpuActMutex; + std::condition_variable fCpuActCond; cmap_t fCntlMap; //!< name->cntl map RlinkAddrMap fIAddrMap; //!< ibus name<->address mapping RlinkAddrMap fRAddrMap; //!< rbus name<->address mapping diff --git a/tools/src/librw11/Rw11UnitTerm.cpp b/tools/src/librw11/Rw11UnitTerm.cpp index 745a57a3..9fc66f1f 100644 --- a/tools/src/librw11/Rw11UnitTerm.cpp +++ b/tools/src/librw11/Rw11UnitTerm.cpp @@ -1,4 +1,4 @@ -// $Id: Rw11UnitTerm.cpp 1083 2018-12-15 19:19:16Z mueller $ +// $Id: Rw11UnitTerm.cpp 1085 2018-12-16 14:11:16Z mueller $ // // Copyright 2013-2018 by Walter F.J. Mueller // @@ -13,6 +13,7 @@ // // Revision History: // Date Rev Version Comment +// 2018-12-17 1085 1.1.6 use std::lock_guard instead of boost // 2018-12-14 1081 1.1.5 use std::bind instead of boost // 2018-12-09 1080 1.1.4 use HasVirt(); Virt() returns ref // 2018-12-01 1076 1.1.3 use unique_ptr @@ -28,8 +29,6 @@ \brief Implemenation of Rw11UnitTerm. */ -#include "boost/thread/locks.hpp" - #include "librtools/RparseUrl.hpp" #include "librtools/RosPrintf.hpp" #include "librtools/Rexception.hpp" @@ -229,7 +228,7 @@ bool Rw11UnitTerm::Snd(const uint8_t* buf, size_t count) bool Rw11UnitTerm::RcvCallback(const uint8_t* buf, size_t count) { // lock connect to protect rxqueue - boost::lock_guard lock(Connect()); + lock_guard lock(Connect()); bool que_empty_old = fRcvQueue.empty(); for (size_t i=0; i lock(Connect()); + lock_guard lock(Connect()); size_t size = fRcvQueue.size(); os << bl << " fRcvQueue.size: " << fRcvQueue.size() << endl; if (size > 0) { diff --git a/tools/src/librw11/Rw11UnitVirt.ipp b/tools/src/librw11/Rw11UnitVirt.ipp index b989e58c..b37ba3c1 100644 --- a/tools/src/librw11/Rw11UnitVirt.ipp +++ b/tools/src/librw11/Rw11UnitVirt.ipp @@ -1,4 +1,4 @@ -// $Id: Rw11UnitVirt.ipp 1080 2018-12-09 20:30:33Z mueller $ +// $Id: Rw11UnitVirt.ipp 1085 2018-12-16 14:11:16Z mueller $ // // Copyright 2013-2018 by Walter F.J. Mueller // @@ -13,6 +13,7 @@ // // Revision History: // Date Rev Version Comment +// 2018-12-17 1085 1.4.1 use std::lock_guard instead of boost // 2018-12-09 1080 1.4 add HasVirt(); return ref for Virt() // 2018-12-01 1076 1.3 use unique_ptr instead of scoped_ptr // 2017-04-15 875 1.2.2 add VirtBase() @@ -29,8 +30,6 @@ \brief Implemenation (inline) of Rw11UnitVirt. */ -#include "boost/thread/locks.hpp" - #include "librtools/RosFill.hpp" #include "Rw11UnitVirt.hpp" @@ -102,7 +101,7 @@ template inline bool Rw11UnitVirt::Attach(const std::string& url, RerrMsg& emsg) { // synchronize with server thread - boost::lock_guard lock(Connect()); + std::lock_guard lock(Connect()); if (fupVirt) Detach(); if (!Enabled()) { emsg.Init("Rw11UnitVirt::Attach","unit not enabled"); @@ -120,7 +119,7 @@ template inline void Rw11UnitVirt::Detach() { // synchronize with server thread - boost::lock_guard lock(Connect()); + std::lock_guard lock(Connect()); if (!fupVirt) return; DetachCleanup(); fupVirt.reset(); diff --git a/tools/src/librwxxtpp/RtclRw11.cpp b/tools/src/librwxxtpp/RtclRw11.cpp index b64b4ec6..0289a9cb 100644 --- a/tools/src/librwxxtpp/RtclRw11.cpp +++ b/tools/src/librwxxtpp/RtclRw11.cpp @@ -1,4 +1,4 @@ -// $Id: RtclRw11.cpp 1082 2018-12-15 13:56:20Z mueller $ +// $Id: RtclRw11.cpp 1087 2018-12-17 08:25:37Z mueller $ // // Copyright 2013-2018 by Walter F.J. Mueller // @@ -13,6 +13,7 @@ // // Revision History: // Date Rev Version Comment +// 2018-12-17 1087 1.0.6 use std::lock_guard instead of boost // 2018-12-15 1082 1.0.5 use lambda instead of bind // 2017-04-16 876 1.0.4 add CpuCommands() // 2017-04-07 868 1.0.3 M_dump: use GetArgsDump and Dump detail @@ -136,7 +137,7 @@ int RtclRw11::ClassCmdConfig(RtclArgs& args) int RtclRw11::M_get(RtclArgs& args) { // synchronize with server thread - boost::lock_guard lock(Obj().Connect()); + lock_guard lock(Obj().Connect()); return fGets.M_get(args); } @@ -146,7 +147,7 @@ int RtclRw11::M_get(RtclArgs& args) int RtclRw11::M_set(RtclArgs& args) { // synchronize with server thread - boost::lock_guard lock(Obj().Connect()); + lock_guard lock(Obj().Connect()); return fSets.M_set(args); } diff --git a/tools/src/librwxxtpp/RtclRw11Cntl.cpp b/tools/src/librwxxtpp/RtclRw11Cntl.cpp index a3e2f1dc..cc46d064 100644 --- a/tools/src/librwxxtpp/RtclRw11Cntl.cpp +++ b/tools/src/librwxxtpp/RtclRw11Cntl.cpp @@ -1,4 +1,4 @@ -// $Id: RtclRw11Cntl.cpp 1082 2018-12-15 13:56:20Z mueller $ +// $Id: RtclRw11Cntl.cpp 1085 2018-12-16 14:11:16Z mueller $ // // Copyright 2013-2018 by Walter F.J. Mueller // @@ -13,6 +13,7 @@ // // Revision History: // Date Rev Version Comment +// 2018-12-17 1085 1.1.4 use std::lock_guard instead of boost // 2018-12-15 1082 1.1.3 use lambda instead of bind // 2017-04-16 877 1.1.2 add UnitCommands(); add Class() // 2017-04-02 865 1.0.2 M_dump: use GetArgsDump and Dump detail @@ -26,8 +27,6 @@ \brief Implemenation of RtclRw11Cntl. */ -#include "boost/thread/locks.hpp" - #include "librtcltools/RtclStats.hpp" #include "librtcltools/RtclOPtr.hpp" @@ -77,7 +76,7 @@ RtclRw11Cntl::~RtclRw11Cntl() int RtclRw11Cntl::M_get(RtclArgs& args) { // synchronize with server thread - boost::lock_guard lock(Obj().Connect()); + lock_guard lock(Obj().Connect()); return fGets.M_get(args); } @@ -87,7 +86,7 @@ int RtclRw11Cntl::M_get(RtclArgs& args) int RtclRw11Cntl::M_set(RtclArgs& args) { // synchronize with server thread - boost::lock_guard lock(Obj().Connect()); + lock_guard lock(Obj().Connect()); return fSets.M_set(args); } diff --git a/tools/src/librwxxtpp/RtclRw11Cpu.cpp b/tools/src/librwxxtpp/RtclRw11Cpu.cpp index ee258b70..55851328 100644 --- a/tools/src/librwxxtpp/RtclRw11Cpu.cpp +++ b/tools/src/librwxxtpp/RtclRw11Cpu.cpp @@ -1,4 +1,4 @@ -// $Id: RtclRw11Cpu.cpp 1082 2018-12-15 13:56:20Z mueller $ +// $Id: RtclRw11Cpu.cpp 1085 2018-12-16 14:11:16Z mueller $ // // Copyright 2013-2018 by Walter F.J. Mueller // @@ -13,6 +13,7 @@ // // Revision History: // Date Rev Version Comment +// 2018-12-17 1085 1.2.22 use std::lock_guard instead of boost // 2018-12-15 1082 1.2.21 use lambda instead of bind // 2018-12-07 1077 1.2.20 use SetLastExpectBlock move semantics // 2018-11-16 1070 1.2.19 use auto; use emplace_back; use range loop @@ -64,8 +65,6 @@ #include #include -#include "boost/thread/locks.hpp" - #include "librtools/RerrMsg.hpp" #include "librtools/RlogMsg.hpp" #include "librtools/RosPrintf.hpp" @@ -1207,7 +1206,7 @@ int RtclRw11Cpu::M_boot(RtclArgs& args) int RtclRw11Cpu::M_get(RtclArgs& args) { // synchronize with server thread - boost::lock_guard lock(Obj().Connect()); + lock_guard lock(Obj().Connect()); return fGets.M_get(args); } @@ -1217,7 +1216,7 @@ int RtclRw11Cpu::M_get(RtclArgs& args) int RtclRw11Cpu::M_set(RtclArgs& args) { // synchronize with server thread - boost::lock_guard lock(Obj().Connect()); + lock_guard lock(Obj().Connect()); return fSets.M_set(args); } @@ -1308,7 +1307,7 @@ int RtclRw11Cpu::M_show(RtclArgs& args) "rw ", "111 "}; { - boost::lock_guard lock(Connect()); + lock_guard lock(Connect()); RlinkCommandList clist; clist.AddWreg(base + Rw11Cpu::kCPAL, 0177572); clist.AddRblk(base + Rw11Cpu::kCPMEMI, ssr, 3); diff --git a/tools/src/librwxxtpp/RtclRw11Unit.cpp b/tools/src/librwxxtpp/RtclRw11Unit.cpp index d76b4ef2..46698a0c 100644 --- a/tools/src/librwxxtpp/RtclRw11Unit.cpp +++ b/tools/src/librwxxtpp/RtclRw11Unit.cpp @@ -1,4 +1,4 @@ -// $Id: RtclRw11Unit.cpp 1082 2018-12-15 13:56:20Z mueller $ +// $Id: RtclRw11Unit.cpp 1085 2018-12-16 14:11:16Z mueller $ // // Copyright 2013-2018 by Walter F.J. Mueller // @@ -13,6 +13,7 @@ // // Revision History: // Date Rev Version Comment +// 2018-12-17 1085 1.3.2 use std::lock_guard instead of boost // 2018-12-15 1082 1.3.1 use lambda instead of bind // 2018-12-01 1076 1.3 use unique_ptr instead of scoped_ptr // 2017-04-08 870 1.2 drop fpCpu, use added Cpu()=0 instead @@ -27,8 +28,6 @@ \brief Implemenation of RtclRw11Unit. */ -#include "boost/thread/locks.hpp" - #include "librtools/Rexception.hpp" #include "librtcltools/RtclStats.hpp" @@ -84,7 +83,7 @@ void RtclRw11Unit::DetachCleanup() int RtclRw11Unit::M_get(RtclArgs& args) { // synchronize with server thread - boost::lock_guard lock(Cpu().Connect()); + lock_guard lock(Cpu().Connect()); return fGets.M_get(args); } @@ -94,7 +93,7 @@ int RtclRw11Unit::M_get(RtclArgs& args) int RtclRw11Unit::M_set(RtclArgs& args) { // synchronize with server thread - boost::lock_guard lock(Cpu().Connect()); + lock_guard lock(Cpu().Connect()); return fSets.M_set(args); } @@ -110,7 +109,7 @@ int RtclRw11Unit::M_attach(RtclArgs& args) RerrMsg emsg; // synchronize with server thread - boost::lock_guard lock(Cpu().Connect()); + lock_guard lock(Cpu().Connect()); DetachCleanup(); if (!Obj().Attach(url, emsg)) return args.Quit(emsg); @@ -126,7 +125,7 @@ int RtclRw11Unit::M_detach(RtclArgs& args) if (!args.AllDone()) return kERR; // synchronize with server thread - boost::lock_guard lock(Cpu().Connect()); + lock_guard lock(Cpu().Connect()); Obj().Detach(); return kOK; } @@ -140,7 +139,7 @@ int RtclRw11Unit::M_virt(RtclArgs& args) "Bad state: fupVirt == nullptr"); // synchronize with server thread - boost::lock_guard lock(Cpu().Connect()); + lock_guard lock(Cpu().Connect()); return fupVirt->DispatchCmd(args); } diff --git a/tools/src/librwxxtpp/RtclRw11Virt.cpp b/tools/src/librwxxtpp/RtclRw11Virt.cpp index d787777a..def05455 100644 --- a/tools/src/librwxxtpp/RtclRw11Virt.cpp +++ b/tools/src/librwxxtpp/RtclRw11Virt.cpp @@ -1,4 +1,4 @@ -// $Id: RtclRw11Virt.cpp 1082 2018-12-15 13:56:20Z mueller $ +// $Id: RtclRw11Virt.cpp 1087 2018-12-17 08:25:37Z mueller $ // // Copyright 2017-2018 by Walter F.J. Mueller // @@ -13,6 +13,7 @@ // // Revision History: // Date Rev Version Comment +// 2018-12-17 1087 1.0.3 use std::lock_guard instead of boost // 2018-12-15 1082 1.0.2 use lambda instead of bind // 2017-04-07 868 1.0.1 M_dump: use GetArgsDump and Dump detail // 2017-03-11 859 1.0 Initial version @@ -65,7 +66,7 @@ RtclRw11Virt::~RtclRw11Virt() int RtclRw11Virt::M_get(RtclArgs& args) { // synchronize with server thread - boost::lock_guard lock(Virt()->Cpu().Connect()); + lock_guard lock(Virt()->Cpu().Connect()); return fGets.M_get(args); } @@ -75,7 +76,7 @@ int RtclRw11Virt::M_get(RtclArgs& args) int RtclRw11Virt::M_set(RtclArgs& args) { // synchronize with server thread - boost::lock_guard lock(Virt()->Cpu().Connect()); + lock_guard lock(Virt()->Cpu().Connect()); return fSets.M_set(args); } diff --git a/tools/src/librwxxtpp/RtclRw11VirtDiskOver.cpp b/tools/src/librwxxtpp/RtclRw11VirtDiskOver.cpp index 6b4e98cb..71b90618 100644 --- a/tools/src/librwxxtpp/RtclRw11VirtDiskOver.cpp +++ b/tools/src/librwxxtpp/RtclRw11VirtDiskOver.cpp @@ -1,4 +1,4 @@ -// $Id: RtclRw11VirtDiskOver.cpp 1082 2018-12-15 13:56:20Z mueller $ +// $Id: RtclRw11VirtDiskOver.cpp 1087 2018-12-17 08:25:37Z mueller $ // // Copyright 2013-2018 by Walter F.J. Mueller // @@ -13,6 +13,7 @@ // // Revision History: // Date Rev Version Comment +// 2018-12-17 1087 1.0.2 use std::lock_guard instead of boost // 2018-12-15 1082 1.0.1 use lambda instead of bind // 2017-03-11 859 1.0 Initial version // --------------------------------------------------------------------------- @@ -58,7 +59,7 @@ int RtclRw11VirtDiskOver::M_flush(RtclArgs& args) if (!args.AllDone()) return kERR; // synchronize with server thread - boost::lock_guard lock(Obj().Cpu().Connect()); + lock_guard lock(Obj().Cpu().Connect()); RerrMsg emsg; if (!Obj().Flush(emsg)) return args.Quit(emsg); return kOK; @@ -73,7 +74,7 @@ int RtclRw11VirtDiskOver::M_list(RtclArgs& args) ostringstream sos; // synchronize with server thread - boost::lock_guard lock(Obj().Cpu().Connect()); + lock_guard lock(Obj().Cpu().Connect()); Obj().List(sos); args.SetResult(sos); return kOK; diff --git a/tools/src/librwxxtpp/RtclRw11VirtDiskRam.cpp b/tools/src/librwxxtpp/RtclRw11VirtDiskRam.cpp index 6d5be8be..0c772284 100644 --- a/tools/src/librwxxtpp/RtclRw11VirtDiskRam.cpp +++ b/tools/src/librwxxtpp/RtclRw11VirtDiskRam.cpp @@ -1,4 +1,4 @@ -// $Id: RtclRw11VirtDiskRam.cpp 1082 2018-12-15 13:56:20Z mueller $ +// $Id: RtclRw11VirtDiskRam.cpp 1087 2018-12-17 08:25:37Z mueller $ // // Copyright 2018- by Walter F.J. Mueller // @@ -13,6 +13,7 @@ // // Revision History: // Date Rev Version Comment +// 2018-12-17 1087 1.0.2 use std::lock_guard instead of boost // 2018-12-15 1082 1.0.1 use lambda instead of bind // 2018-10-28 1063 1.0 Initial version // --------------------------------------------------------------------------- @@ -58,7 +59,7 @@ int RtclRw11VirtDiskRam::M_list(RtclArgs& args) ostringstream sos; // synchronize with server thread - boost::lock_guard lock(Obj().Cpu().Connect()); + lock_guard lock(Obj().Cpu().Connect()); Obj().List(sos); args.SetResult(sos); return kOK;