14 using std::unique_ptr;
41 return std::thread::hardware_concurrency();
48 inline static void sleep(
const uint64_t milliseconds) {
49 std::this_thread::sleep_for(std::chrono::duration<uint64_t, std::milli>(milliseconds));
69 inline virtual void stop() {
85 virtual void run() = 0;
89 auto threadPtr =
static_cast<Thread*
>(thread);
91 if (threadPtr->autoDelete ==
true) {
92 threadPtr->stlThread.detach();
virtual void run()=0
Abstract run() method, should be implemented by subclassed class, will be called after spawn by start...
virtual ~Thread()
Public destructor.
static void sleep(const uint64_t milliseconds)
sleeps current thread for given time in milliseconds
virtual void start()
Starts this objects thread.
void join()
Blocks caller thread until this thread has been terminated.
volatile bool stopRequested
static void threadRun(void *thread)
static int getHardwareThreadCount()
bool isStopRequested()
Returns if stop has been requested.
virtual void stop()
Requests that this thread should be stopped.
#define FORBID_CLASS_COPY(CLASS)