STE-Industries: utilities testing
GraphicSpace::Thread Class Reference

#include "Thread.h"

Collaboration diagram for GraphicSpace::Thread:
Collaboration graph

Public Types

typedef void *(* ThreadFunctionType) (void *Argument)
 

Public Member Functions

 Thread (const Thread &thisThread)=delete
 
 Thread (Thread &&thisThread)=delete
 
 Thread (void) noexcept
 
 ~Thread (void) noexcept
 
void Join (void) noexcept(false)
 
void Kill (void) noexcept(false)
 
Threadoperator= (const Thread &thisThread)=delete
 
Threadoperator= (Thread &&thisThread)=delete
 
void Start (ThreadFunctionType ThreadFunction, void *Argument) noexcept(false)
 

Static Public Member Functions

static void Finalize (void) noexcept
 
static void Initialize (void) noexcept(false)
 

Private Attributes

pthread_t ThreadId
 

Static Private Attributes

static constexpr unsigned int ATTRIBUTE_INIT_OK = 0
 
static constexpr unsigned int ATTRIBUTE_SET_OK = 0
 
static pthread_t MainThreadId
 
static constexpr unsigned int PARAMETER_GET_OK = 0
 
static constexpr unsigned int THREAD_CREATE_OK = 0
 
static constexpr unsigned int THREAD_JOIN_OK = 0
 
static pthread_attr_t ThreadAttribute
 

Detailed Description

The Thread class represents a thread.

Definition at line 28 of file Thread.h.

Member Typedef Documentation

◆ ThreadFunctionType

GraphicSpace::Thread::ThreadFunctionType

Type of the thread function.

Definition at line 70 of file Thread.h.

Constructor & Destructor Documentation

◆ Thread() [1/3]

GraphicSpace::Thread::Thread ( void  )
noexcept
Description:
Constructor.
Exceptions
None.
Returns
Not applicable.

Definition at line 37 of file Thread.cpp.

◆ Thread() [2/3]

GraphicSpace::Thread::Thread ( const Thread thisThread)
delete

◆ Thread() [3/3]

GraphicSpace::Thread::Thread ( Thread &&  thisThread)
delete

◆ ~Thread()

GraphicSpace::Thread::~Thread ( void  )
noexcept
Description:
Destructor.
Exceptions
None.
Returns
Not applicable.
Note
If the Thread is running, it is killed.

Definition at line 54 of file Thread.cpp.

Member Function Documentation

◆ Finalize()

void GraphicSpace::Thread::Finalize ( void  )
staticnoexcept
Description:
Finalize the thread management.
Exceptions
None.
Returns
None.

Definition at line 115 of file Thread.cpp.

References IgnoreValue.

Referenced by main().

Here is the caller graph for this function:

◆ Initialize()

void GraphicSpace::Thread::Initialize ( void  )
staticnoexcept
Description:
Initialize the thread management.
Exceptions
SystemExceptionType::THREADINITIALIZATION_FAILEDIf the initialization fails.
Returns
None.
Note
If this function is not called before any thread operation, including the definition of a Thread object, the behavior is undefined.
See also
ATTRIBUTE_INIT_OK
ATTRIBUTE_SET_OK
THREAD_CREATE_OK

Definition at line 79 of file Thread.cpp.

References GraphicSpace::THREAD_INITIALIZATION_FAILED.

Referenced by main().

Here is the caller graph for this function:

◆ Join()

void GraphicSpace::Thread::Join ( void  )
noexcept
Description:
Make the calling thread wait, until the Thread on which the operation is invoked is terminated.
Exceptions
SystemExceptionType::INVALID_THREAD_OPERATIONIf the Thread was not started.
Returns
None.
See also
THREAD_JOIN_OK

Definition at line 197 of file Thread.cpp.

References GraphicSpace::INVALID_THREAD_OPERATION.

◆ Kill()

void GraphicSpace::Thread::Kill ( void  )
noexcept
Description:
Kill the thread.
Exceptions
SystemExceptionType::INVALID_THREAD_OPERATIONIf the Thread was not started.
Returns
None.
Note
After having been killed, the Thread can be started again.

Definition at line 174 of file Thread.cpp.

References IgnoreValue, and GraphicSpace::INVALID_THREAD_OPERATION.

◆ operator=() [1/2]

Thread& GraphicSpace::Thread::operator= ( const Thread thisThread)
delete

◆ operator=() [2/2]

Thread& GraphicSpace::Thread::operator= ( Thread &&  thisThread)
delete

◆ Start()

void GraphicSpace::Thread::Start ( ThreadFunctionType  ThreadFunction,
void *  Argument 
)
noexcept
Description:
Start the thread.
Parameters
ThreadFunctionPointer to the Thread object.
ArgumentPointer to the Thread argument.
Exceptions
SystemExceptionType::THREAD_CREATION_FAILEDIf the thread creation fails or if scheduling parameters setting fails.
SystemExceptionType::INVALID_THREAD_OPERATIONIf the Thread was already started.
Returns
None.
Note
After started, the Thread cannot be started again, unless it has terminated, or it has been killed.
See also
THREAD_CREATE_OK

Definition at line 148 of file Thread.cpp.

References GraphicSpace::INVALID_THREAD_OPERATION, and GraphicSpace::THREAD_CREATION_FAILED.

Member Data Documentation

◆ ATTRIBUTE_INIT_OK

GraphicSpace::Thread::ATTRIBUTE_INIT_OK = 0
staticconstexprprivate

Value returned by pthread_attr_init when the operation succeeds.

Definition at line 34 of file Thread.h.

◆ ATTRIBUTE_SET_OK

GraphicSpace::Thread::ATTRIBUTE_SET_OK = 0
staticconstexprprivate

Value returned by pthread_attr_setsched_policy, pthread_attr_setschedparam, pthread_attr_setdetachstate and pthread_attr_setinheritsched when the operation succeeds.

Definition at line 40 of file Thread.h.

◆ MainThreadId

GraphicSpace::Thread::MainThreadId
staticprivate

Identifier of the initial thread.

Definition at line 64 of file Thread.h.

◆ PARAMETER_GET_OK

GraphicSpace::Thread::PARAMETER_GET_OK = 0
staticconstexprprivate

Value returned by sched_getparam when the operation succeeds.

Definition at line 44 of file Thread.h.

◆ THREAD_CREATE_OK

GraphicSpace::Thread::THREAD_CREATE_OK = 0
staticconstexprprivate

Value returned by pthread_create when the operation succeeds.

Definition at line 48 of file Thread.h.

◆ THREAD_JOIN_OK

GraphicSpace::Thread::THREAD_JOIN_OK = 0
staticconstexprprivate

Value returned by pthread_join when the operation succeeds.

Definition at line 52 of file Thread.h.

◆ ThreadAttribute

GraphicSpace::Thread::ThreadAttribute
staticprivate

Thread attributes.

Definition at line 60 of file Thread.h.

◆ ThreadId

GraphicSpace::Thread::ThreadId
private

Thread identifier.

Definition at line 56 of file Thread.h.


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