1
0
mirror of https://github.com/wfjm/w11.git synced 2026-02-05 08:15:19 +00:00

use std::thread instead of boost; final boost cleanup

- no boost:: classes used anymore
- no boost/*.hpp headers included anymore
- significantly improved compilation speed
This commit is contained in:
wfjm
2018-12-19 11:53:54 +01:00
parent dcaf39ff84
commit 4e2f1c3d19
16 changed files with 71 additions and 70 deletions

View File

@@ -1,4 +1,4 @@
// $Id: RlinkPortCuff.cpp 1081 2018-12-14 22:29:42Z mueller $
// $Id: RlinkPortCuff.cpp 1088 2018-12-17 17:37:00Z mueller $
//
// Copyright 2012-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 1088 1.1.9 use std::thread instead of boost
// 2018-12-14 1081 1.1.8 use std::bind instead of boost
// 2018-11-09 1066 1.1.7 use auto
// 2018-10-27 1059 1.1.6 coverity fixup (uncaught exception in dtor)
@@ -244,7 +245,7 @@ bool RlinkPortCuff::Open(const std::string& url, RerrMsg& emsg)
libusb_set_pollfd_notifiers(fpUsbContext, ThunkPollfdAdd,
ThunkPollfdRemove, this);
fDriverThread = boost::thread(std::bind(&RlinkPortCuff::Driver, this));
fDriverThread = thread([this](){ Driver(); });
fIsOpen = true;
@@ -275,13 +276,7 @@ void RlinkPortCuff::Cleanup()
CloseFd(fFdWrite);
// wait till driver thread terminates
// use timed join, throw in case driver doesn't stop
if (fDriverThread.get_id() != boost::thread::id()) {
if (!fDriverThread.timed_join(boost::posix_time::milliseconds(500))) {
throw Rexception("RlinkPortCuff::Cleanup()",
"driver thread failed to stop");
}
}
if (fDriverThread.joinable()) fDriverThread.join();
// cleanup pipes
CloseFd(fFdRead);
@@ -332,7 +327,7 @@ bool RlinkPortCuff::OpenPipe(int& fdread, int& fdwrite, RerrMsg& emsg)
//------------------------------------------+-----------------------------------
//! FIXME_docs
// executed in separate boost thread !!
// executed in separate thread !!
void RlinkPortCuff::Driver()
{
try {

View File

@@ -1,4 +1,4 @@
// $Id: RlinkPortCuff.hpp 1060 2018-10-27 11:32:39Z mueller $
// $Id: RlinkPortCuff.hpp 1088 2018-12-17 17:37:00Z mueller $
//
// Copyright 2012-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 1088 1.0.2 use std::thread instead of boost
// 2013-01-02 467 1.0.1 get cleanup code right; add USBErrorName()
// 2012-12-26 465 1.0 Initial version
// ---------------------------------------------------------------------------
@@ -33,8 +34,7 @@
#include <vector>
#include <deque>
#include "boost/thread/thread.hpp"
#include <thread>
namespace Retro {
@@ -72,7 +72,7 @@ namespace Retro {
protected:
int fFdReadDriver; //!< fd for read (driver end)
int fFdWriteDriver; //!< fd for write (driver end)
boost::thread fDriverThread; //!< driver thread
std::thread fDriverThread; //!< driver thread
libusb_context* fpUsbContext;
libusb_device** fpUsbDevList;
ssize_t fUsbDevCount;

View File

@@ -1,4 +1,4 @@
// $Id: RlinkServer.cpp 1085 2018-12-16 14:11:16Z mueller $
// $Id: RlinkServer.cpp 1088 2018-12-17 17:37:00Z mueller $
//
// Copyright 2013-2018 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
//
@@ -13,7 +13,7 @@
//
// Revision History:
// Date Rev Version Comment
// 2018-12-17 1085 1.2.8 use std::lock_guard instead of boost
// 2018-12-17 1088 2.2.8 use std::lock_guard, std::thread 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
@@ -36,6 +36,8 @@
\brief Implemenation of RlinkServer.
*/
#include <unistd.h>
#include "librtools/Rexception.hpp"
#include "librtools/RosFill.hpp"
#include "librtools/RosPrintf.hpp"
@@ -188,7 +190,7 @@ void RlinkServer::GetAttnInfo(AttnArgs& args)
//! FIXME_docs
void RlinkServer::RemoveAttnHandler(uint16_t mask, void* cdata)
{
{
lock_guard<RlinkConnect> lock(*fspConn);
AttnId id(mask, cdata);
@@ -269,7 +271,8 @@ void RlinkServer::Start()
//! FIXME_docs
void RlinkServer::Stop()
{
{
if (!IsActive()) return;
fELoop.Stop();
Wakeup();
fServerThread.join();
@@ -280,7 +283,7 @@ void RlinkServer::Stop()
//! FIXME_docs
void RlinkServer::Resume()
{
{
StartOrResume(true);
return;
}
@@ -289,9 +292,9 @@ void RlinkServer::Resume()
//! FIXME_docs
void RlinkServer::Wakeup()
{
{
uint64_t one(1);
int irc = write(fWakeupEvent, &one, sizeof(one));
int irc = ::write(fWakeupEvent, &one, sizeof(one));
if (irc < 0)
throw Rexception("RlinkServer::Wakeup()",
"write() to eventfd failed: ", errno);
@@ -302,7 +305,7 @@ void RlinkServer::Wakeup()
//! FIXME_docs
void RlinkServer::SignalAttnNotify(uint16_t apat)
{
{
// only called under lock !!
if (apat & fAttnNotiPatt) {
RlogMsg lmsg(LogFile(), 'W');
@@ -322,8 +325,8 @@ void RlinkServer::SignalAttnNotify(uint16_t apat)
*/
bool RlinkServer::IsActive() const
{
return fServerThread.get_id() != boost::thread::id();
{
return fServerThread.joinable();
}
//------------------------------------------+-----------------------------------
@@ -334,7 +337,7 @@ bool RlinkServer::IsActive() const
bool RlinkServer::IsActiveInside() const
{
return IsActive() && boost::this_thread::get_id() == fServerThread.get_id();
return IsActive() && this_thread::get_id() == fServerThread.get_id();
}
//------------------------------------------+-----------------------------------
@@ -346,7 +349,7 @@ bool RlinkServer::IsActiveInside() const
bool RlinkServer::IsActiveOutside() const
{
return IsActive() && boost::this_thread::get_id() != fServerThread.get_id();
return IsActive() && this_thread::get_id() != fServerThread.get_id();
}
//------------------------------------------+-----------------------------------
@@ -421,8 +424,7 @@ void RlinkServer::StartOrResume(bool resume)
// and start server thread
fELoop.UnStop();
fServerThread = boost::thread(std::bind(&RlinkServerEventLoop::EventLoop,
&fELoop));
fServerThread = thread([this](){ fELoop.EventLoop(); });
if (resume) {
RerrMsg emsg;
@@ -557,7 +559,7 @@ int RlinkServer::WakeupHandler(const pollfd& pfd)
if (pfd.revents & (~pfd.events)) return -1;
uint64_t buf;
int irc = read(fWakeupEvent, &buf, sizeof(buf));
int irc = ::read(fWakeupEvent, &buf, sizeof(buf));
if (irc < 0)
throw Rexception("RlinkServer::WakeupHandler()",
"read() from eventfd failed: ", errno);

View File

@@ -1,4 +1,4 @@
// $Id: RlinkServer.hpp 1084 2018-12-16 12:23:53Z mueller $
// $Id: RlinkServer.hpp 1088 2018-12-17 17:37:00Z 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 1088 2.2.6 use std::thread instead of boost
// 2018-12-16 1084 2.2.5 use =delete for noncopyable instead of boost
// 2018-12-15 1083 2.2.4 for std::function setups: use rval ref and move
// 2018-12-14 1081 2.2.3 use std::function instead of boost
@@ -42,8 +43,7 @@
#include <list>
#include <memory>
#include <functional>
#include "boost/thread/thread.hpp"
#include <thread>
#include "librtools/Rstats.hpp"
@@ -179,7 +179,7 @@ namespace Retro {
std::list<actnhdl_t> fActnList;
ReventFd fWakeupEvent;
RlinkServerEventLoop fELoop;
boost::thread fServerThread;
std::thread fServerThread;
uint16_t fAttnPatt; //!< current attn pattern
uint16_t fAttnNotiPatt; //!< attn notifier pattern
uint32_t fTraceLevel; //!< trace level