Library of Assembled Shared Sources
lass::util::Thread Class Referenceabstract

A base class for threads. More...

#include <thread.h>

Inheritance diagram for lass::util::Thread:
Collaboration diagram for lass::util::Thread:

Public Member Functions

virtual ~Thread ()
 
void bind (size_t processor)
 bind this thread to a processor (this as in this-pointer)
 

Static Public Member Functions

static void bindCurrent (size_t processor)
 bind current thread to a processor (current as in callee's context)
 

Static Public Attributes

static constexpr size_t anyProcessor = size_t(-1)
 argument for Thread::bind to unbind the thread so it runs on any processor
 

Detailed Description

A base class for threads.

The virtual function doRun() needs to be overriden and after creation of the thread on the heap or stack, the thread is in a state ready to be run.
The run() function actually starts the thread.

JOINABLE threads can be waited for, DETACHED threads can not be waited for.

Definition at line 206 of file thread.h.

Constructor & Destructor Documentation

◆ ~Thread()

lass::util::Thread::~Thread ( )
virtual
Warning
The destructor will not join joinable threads first. You have to do it yourself. Why? Well, as long as the worker thread is executing doRun(), it needs the complete thread object. By the time we get in ~Thread(), the derived class is already destructed and the thread would now be acting on a half destructed object. That can't be good, can it? So make sure you call join() before the destructor is invoked.

Definition at line 243 of file thread.cpp.


The documentation for this class was generated from the following files: