use boost::scoped_thread in IThreaded

This commit is contained in:
Lion Kortlepel 2024-01-19 14:42:21 +01:00
parent 9502048525
commit 3de142a6d0
No known key found for this signature in database
GPG Key ID: 4322FF2B4C71259B

View File

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