A class that will run a single (lambda) function in a separate thread. More...
#include <threading.h>
Public Member Functions | |
int32_t | innerFunction (void) override final |
The internal thread function, runs the supplied function. More... | |
ThreadedFunction (std::function< void()> const &f, bool runNow=true) | |
Construct the object. More... | |
~ThreadedFunction () | |
![]() | |
XsThreadId | getThreadId (void) const |
bool | isAlive (void) volatile const noexcept |
bool | isRunning (void) volatile const noexcept |
Returns whether the thread is currently running. More... | |
bool | isTerminating () volatile const noexcept |
Returns whether the thread should (have) terminate(d) More... | |
bool | setPriority (XsThreadPriority pri) |
Sets the priority of the thread. More... | |
virtual void | signalStopThread (void) |
Tells the thread to stop but does not wait for it to end. More... | |
StandardThread () | |
bool | startThread (const char *name=NULL) |
Starts the thread. More... | |
void | stopThread (void) noexcept |
Tells the thread to stop and waits for it to end. More... | |
virtual | ~StandardThread () |
Private Attributes | |
std::function< void()> | m_func |
Additional Inherited Members | |
![]() | |
virtual void | exitFunction (void) |
Virtual exit function. More... | |
virtual void | initFunction (void) |
Virtual initialization function. More... | |
XsThread | threadHandle () const |
Return the thread handle. More... | |
![]() | |
pthread_attr_t | m_attr |
Duplicates m_stop functionality for external dependent classes such as Semaphore. More... | |
bool | m_running |
Indicates that the thread is running. More... | |
volatile std::atomic_bool | m_stop |
Indicates that the thread should stop. Derived classes should check isTerminating() instead of directly polling this value when checking if the thread should stop. However, there are some cases (tests, SignallingThread) where direct access from within the class is desired, which is why the vlaue is protected instead of private. More... | |
volatile std::atomic_bool | m_yieldOnZeroSleep |
When true, a sleep value of 0 returned by innerFunction will trigger a thread yield operation. When false, the next cycle is started immediately. More... | |
A class that will run a single (lambda) function in a separate thread.
Definition at line 297 of file threading.h.
|
inline |
Construct the object.
f | The desired (lambda) function to run |
runNow | Start the thread immediately (default = true) |
Definition at line 305 of file threading.h.
|
inline |
Definition at line 311 of file threading.h.
|
inlinefinaloverridevirtual |
The internal thread function, runs the supplied function.
Reimplemented from xsens::StandardThread.
Definition at line 317 of file threading.h.
|
private |
Definition at line 299 of file threading.h.