commonlib
ThreadEx Class Referenceabstract

ThreadEx class for working with threads. More...

#include <threadex.h>

Inheritance diagram for ThreadEx:
FunctionThread TimerThread

Public Member Functions

virtual void start ()
 Starts the execution of a thread.
 
virtual void stop ()
 Terminate and wait for the thread to terminate.
 
void terminate ()
 Terminate sets the thread's Terminated property to true, signaling that the thread should be terminated as soon as possible.
 
void waitFor ()
 Waits for the thread to terminate.
 
const ThreadExPriority & getPriority () const
 Get thread's scheduling priority relative to other threads in the process. More...
 
void setPriority (ThreadExPriority priority)
 Set thread's scheduling priority relative to other threads in the process. More...
 
std::recursive_mutex & getLock ()
 Get thread's locking object. More...
 
const std::atomic< bool > & getTerminated () const
 Returns thread's terminated signal. More...
 
const std::atomic< bool > & getFinished () const
 Returns true if thread has already been finished. More...
 
bool getStarted () const
 Returns true if thread is started. More...
 
ThreadExceptionAdapter * getExceptionAdapter ()
 Returns exception information holder. More...
 
void setExceptionAdapter (ThreadExceptionAdapter *exceptionAdapter)
 Sets exception information holder. More...
 
const std::thread::id getThreadId () const
 Returns thread id.
 

Protected Member Functions

virtual void execute ()=0
 Provides an abstract or pure virtual method to contain the code which executes when the thread is run.
 
void setThreadName (const char *name)
 Set current thread name (you must call it from the thread)
 

Protected Attributes

std::recursive_mutex lock
 
std::atomic< bool > terminated
 
std::atomic< bool > finished
 
ThreadExceptionAdapter * exceptionAdapter {}
 

Detailed Description

ThreadEx class for working with threads.

Member Function Documentation

◆ getExceptionAdapter()

ThreadExceptionAdapter* ThreadEx::getExceptionAdapter ( )

Returns exception information holder.

Returns
Exception object

◆ getFinished()

const std::atomic<bool>& ThreadEx::getFinished ( ) const

Returns true if thread has already been finished.

Returns
Finished status.

◆ getLock()

std::recursive_mutex& ThreadEx::getLock ( )

Get thread's locking object.

Returns
std::recursive_mutex& locking thread object

◆ getPriority()

const ThreadExPriority& ThreadEx::getPriority ( ) const

Get thread's scheduling priority relative to other threads in the process.

Returns
Current ThreadExPriority value

◆ getStarted()

bool ThreadEx::getStarted ( ) const

Returns true if thread is started.

Returns
Thread is started.

◆ getTerminated()

const std::atomic<bool>& ThreadEx::getTerminated ( ) const

Returns thread's terminated signal.

Returns
Terminated signal.

◆ setExceptionAdapter()

void ThreadEx::setExceptionAdapter ( ThreadExceptionAdapter *  exceptionAdapter)

Sets exception information holder.

Parameters
Exceptionadapter

◆ setPriority()

void ThreadEx::setPriority ( ThreadExPriority  priority)

Set thread's scheduling priority relative to other threads in the process.

Parameters
prioritya new priority value.

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