1
0
mirror of https://github.com/wfjm/w11.git synced 2026-01-13 15:37:43 +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:
wfjm 2018-12-18 10:22:35 +01:00
parent 783778f2bb
commit dcaf39ff84
24 changed files with 126 additions and 125 deletions

View File

@ -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

View File

@ -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());

View File

@ -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;

View File

@ -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;

View File

@ -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

View File

@ -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;
}

View File

@ -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()();

View File

@ -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 <W.F.J.Mueller@gsi.de>
//
@ -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 <iostream>
#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<RlinkConnect> lock(Obj());
lock_guard<RlinkConnect> 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<RlinkConnect> lock(Obj());
lock_guard<RlinkConnect> lock(Obj());
return fSets.M_set(args);
}

View File

@ -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 <W.F.J.Mueller@gsi.de>
//
@ -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<RlinkConnect> lock(Obj().Connect());
lock_guard<RlinkConnect> 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<RlinkConnect> lock(Obj().Connect());
lock_guard<RlinkConnect> lock(Obj().Connect());
return fSets.M_set(args);
}

View File

@ -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 <W.F.J.Mueller@gsi.de>
// Copyright 2011-2018 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
//
// 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 <time.h>
#include <errno.h>
#include "boost/thread/locks.hpp"
#include <iostream>
#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<RlogFile> lock(*this);
lock_guard<RlogFile> lock(*this);
if (tag) {
struct timespec ts;

View File

@ -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 <W.F.J.Mueller@gsi.de>
//
@ -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 <string>
#include <ostream>
#include <fstream>
#include "boost/thread/mutex.hpp"
#include <mutex>
#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

View File

@ -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 <W.F.J.Mueller@gsi.de>
//
@ -21,8 +21,6 @@
\brief Implemenation of RlogMsg.
*/
#include "boost/thread/locks.hpp"
#include "RlogFile.hpp"
#include "RlogMsg.hpp"

View File

@ -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 <W.F.J.Mueller@gsi.de>
//
@ -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<RlinkConnect> lock(Connect());
lock_guard<RlinkConnect> 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<RlinkConnect> lock(Connect());
lock_guard<RlinkConnect> lock(Connect());
RosFill bl(ind);
os << bl << (text?text:"--") << "Rw11CntlDEUNA @ " << this << endl;

View File

@ -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 <W.F.J.Mueller@gsi.de>
//
@ -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 <vector>
#include <map>
#include <algorithm>
#include "boost/date_time/posix_time/posix_time_types.hpp"
#include <chrono>
#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<boost::mutex> lock(fCpuActMutex);
lock_guard<mutex> 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<boost::mutex> lock(fCpuActMutex);
lock_guard<mutex> 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<double> timeout(chrono::duration<double>::max());
if (tout.IsPositive())
timeout = chrono::duration<double>(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<boost::mutex> lock(fCpuActMutex);
unique_lock<mutex> 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();

View File

@ -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 <W.F.J.Mueller@gsi.de>
//
@ -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 <vector>
#include <memory>
#include <map>
#include "boost/thread/locks.hpp"
#include "boost/thread/condition_variable.hpp"
#include <mutex>
#include <condition_variable>
#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

View File

@ -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 <W.F.J.Mueller@gsi.de>
//
@ -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<RlinkConnect> lock(Connect());
lock_guard<RlinkConnect> lock(Connect());
bool que_empty_old = fRcvQueue.empty();
for (size_t i=0; i<count; i++) {
@ -255,7 +254,7 @@ void Rw11UnitTerm::Dump(std::ostream& os, int ind, const char* text,
os << bl << " fToEnpc: " << fToEnpc << endl;
os << bl << " fTi7bit: " << fTi7bit << endl;
{
boost::lock_guard<RlinkConnect> lock(Connect());
lock_guard<RlinkConnect> lock(Connect());
size_t size = fRcvQueue.size();
os << bl << " fRcvQueue.size: " << fRcvQueue.size() << endl;
if (size > 0) {

View File

@ -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 <W.F.J.Mueller@gsi.de>
//
@ -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 <class TV>
inline bool Rw11UnitVirt<TV>::Attach(const std::string& url, RerrMsg& emsg)
{
// synchronize with server thread
boost::lock_guard<RlinkConnect> lock(Connect());
std::lock_guard<RlinkConnect> lock(Connect());
if (fupVirt) Detach();
if (!Enabled()) {
emsg.Init("Rw11UnitVirt::Attach","unit not enabled");
@ -120,7 +119,7 @@ template <class TV>
inline void Rw11UnitVirt<TV>::Detach()
{
// synchronize with server thread
boost::lock_guard<RlinkConnect> lock(Connect());
std::lock_guard<RlinkConnect> lock(Connect());
if (!fupVirt) return;
DetachCleanup();
fupVirt.reset();

View File

@ -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 <W.F.J.Mueller@gsi.de>
//
@ -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<RlinkConnect> lock(Obj().Connect());
lock_guard<RlinkConnect> 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<RlinkConnect> lock(Obj().Connect());
lock_guard<RlinkConnect> lock(Obj().Connect());
return fSets.M_set(args);
}

View File

@ -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 <W.F.J.Mueller@gsi.de>
//
@ -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<RlinkConnect> lock(Obj().Connect());
lock_guard<RlinkConnect> 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<RlinkConnect> lock(Obj().Connect());
lock_guard<RlinkConnect> lock(Obj().Connect());
return fSets.M_set(args);
}

View File

@ -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 <W.F.J.Mueller@gsi.de>
//
@ -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 <memory>
#include <sstream>
#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<RlinkConnect> lock(Obj().Connect());
lock_guard<RlinkConnect> 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<RlinkConnect> lock(Obj().Connect());
lock_guard<RlinkConnect> lock(Obj().Connect());
return fSets.M_set(args);
}
@ -1308,7 +1307,7 @@ int RtclRw11Cpu::M_show(RtclArgs& args)
"rw ",
"111 "};
{
boost::lock_guard<RlinkConnect> lock(Connect());
lock_guard<RlinkConnect> lock(Connect());
RlinkCommandList clist;
clist.AddWreg(base + Rw11Cpu::kCPAL, 0177572);
clist.AddRblk(base + Rw11Cpu::kCPMEMI, ssr, 3);

View File

@ -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 <W.F.J.Mueller@gsi.de>
//
@ -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<RlinkConnect> lock(Cpu().Connect());
lock_guard<RlinkConnect> 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<RlinkConnect> lock(Cpu().Connect());
lock_guard<RlinkConnect> 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<RlinkConnect> lock(Cpu().Connect());
lock_guard<RlinkConnect> 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<RlinkConnect> lock(Cpu().Connect());
lock_guard<RlinkConnect> 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<RlinkConnect> lock(Cpu().Connect());
lock_guard<RlinkConnect> lock(Cpu().Connect());
return fupVirt->DispatchCmd(args);
}

View File

@ -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 <W.F.J.Mueller@gsi.de>
//
@ -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<RlinkConnect> lock(Virt()->Cpu().Connect());
lock_guard<RlinkConnect> 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<RlinkConnect> lock(Virt()->Cpu().Connect());
lock_guard<RlinkConnect> lock(Virt()->Cpu().Connect());
return fSets.M_set(args);
}

View File

@ -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 <W.F.J.Mueller@gsi.de>
//
@ -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<RlinkConnect> lock(Obj().Cpu().Connect());
lock_guard<RlinkConnect> 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<RlinkConnect> lock(Obj().Cpu().Connect());
lock_guard<RlinkConnect> lock(Obj().Cpu().Connect());
Obj().List(sos);
args.SetResult(sos);
return kOK;

View File

@ -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 <W.F.J.Mueller@gsi.de>
//
@ -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<RlinkConnect> lock(Obj().Cpu().Connect());
lock_guard<RlinkConnect> lock(Obj().Cpu().Connect());
Obj().List(sos);
args.SetResult(sos);
return kOK;