mirror of
https://github.com/BeamMP/BeamMP-Server.git
synced 2025-07-02 15:55:30 +00:00
use boost::scoped_thread in IThreaded
This commit is contained in:
parent
9502048525
commit
3de142a6d0
@ -1,5 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <boost/thread/scoped_thread.hpp>
|
||||
#include <thread>
|
||||
|
||||
// pure virtual class to be inherited from by classes which intend to be threaded
|
||||
@ -9,16 +10,14 @@ public:
|
||||
// invokes operator() on this object
|
||||
: mThread() { }
|
||||
virtual ~IThreaded() noexcept {
|
||||
if (mThread.joinable()) {
|
||||
mThread.join();
|
||||
}
|
||||
mThread.interrupt();
|
||||
}
|
||||
|
||||
virtual void Start() final {
|
||||
mThread = std::thread([this] { (*this)(); });
|
||||
mThread = boost::scoped_thread<>([this] { (*this)(); });
|
||||
}
|
||||
virtual void operator()() = 0;
|
||||
|
||||
protected:
|
||||
std::thread mThread;
|
||||
boost::scoped_thread<> mThread {};
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user