This class is a wrapper in order to manage threads according to the object oriented style.
More...
#include <Thread.h>
|
virtual void | run ()=0 |
| this method has to be overridden to provide the logic for the thread. It has to contain the code that will be executed in the thread
|
|
|
bool | isRunning_ |
| true if the thread is running
|
|
bool | hasFinished_ |
| true if the thread has finished.
|
|
bool | joinHasFinished_ |
| if true, a call to pthread_join has completed and a further pthread_cancel / pthread_join call is unsafe
|
|
bool | permanent_ |
|
pthread_t | tid_ |
| Id of this thread.
|
|
This class is a wrapper in order to manage threads according to the object oriented style.
void fesa::Thread::AdjustProcessScheduling |
( |
| ) |
|
|
static |
The process priority can only be adjusted in the main thread. It needs to be adjusted to the maximal thread priority since it sets the limit of the thread priorities of this process.
- Exceptions
-
Thread * fesa::Thread::getById |
( |
pthread_t |
id | ) |
|
|
static |
Returns the Thread object associated with the given id. Throws FesaException if the id is unknown.
- Parameters
-
id | the thread id (pthread_t form, not gettid() form). |
std::string fesa::Thread::getCurrentThreadName |
( |
| ) |
|
|
static |
- Returns
- the current thread's name.
pthread_t fesa::Thread::getID |
( |
| ) |
const |
|
inline |
Get the process ID.
- Returns
- the process ID
int32_t fesa::Thread::getPriority |
( |
| ) |
const |
|
inline |
Get the priority of the thread.
- Returns
- Current priority
std::string fesa::Thread::getThreadName |
( |
pthread_t |
threadId | ) |
|
|
static |
Get the name of the thread by its id.
- Parameters
-
threadId | The id of a thread |
- Returns
- The name of the thread
const std::set< const Thread * > fesa::Thread::getThreads |
( |
| ) |
|
|
static |
- Returns
- a set containing pointer to all the running threads that have been registered.
bool fesa::Thread::isRunning |
( |
| ) |
const |
|
inline |
Check if the thread is running.
- Returns
- true if the the thread is running
int fesa::Thread::join |
( |
void ** |
status | ) |
|
IMPORTANT: calling this on a thread which is not permanent causes undefined behaviour. Blocks until this thread finishes. If the thread has already finished, returns immediately. A thread can only be joined once.
- Parameters
-
[out] | status | (optional, can be NULL) the return value of the thread. |
- Returns
- 0 on success, a standard error code otherwise.
void fesa::Thread::registerThreadId |
( |
pthread_t |
threadId, |
|
|
Thread * |
thread |
|
) |
| |
|
static |
Associate a thread id with a name.
- Parameters
-
threadId | The id of the thread |
threadName | The name of the thread |
void fesa::Thread::registerThreadIdName |
( |
pthread_t |
threadId, |
|
|
const std::string & |
threadName |
|
) |
| |
|
static |
Associate a thread id with a name.
- Parameters
-
threadId | The id of the thread |
threadName | The name of the thread |
void fesa::Thread::setAffinity |
( |
cpu_set_t |
affinity | ) |
|
Set the affinity of the thread.
- Parameters
-
affinity | The affinity of the thread |
- Exceptions
-
void fesa::Thread::setDetachState |
( |
int32_t |
state | ) |
|
|
inline |
Modify the detach state of the thread.
- Parameters
-
state | New thread state. See pthread_attr_setdetachstate() for info on what values are possible |
void fesa::Thread::setPriority |
( |
int32_t |
priority | ) |
|
Set the priority of the thread.
- Parameters
-
priority | Priority of the thread |
- Exceptions
-
void fesa::Thread::start |
( |
bool |
blockingMode, |
|
|
const std::string & |
threadName, |
|
|
bool |
permanent = true |
|
) |
| |
Starts this thread and gives it a name. If blockingMode is true, the thread is started in blocking mode and this method returns once the thread has finished. Otherwise, this method returns immediately. If permanent is true, the thread is joinable and will be stopped automatically when the process stops. Otherwise: -It is the responsibility of the caller to ensure that the thread finishes shortly. -The thread can't be joined (it is created in detached state). -If the process is shut down while the thread is still running, it will be stopped without notice. -blockingMode is ignored and the current thread is not blocked.
- Parameters
-
blockingMode | If true, create a new thread and block the calling thread until the new thread finishes. If false, create a new thread and return |
threadName | The name of the thread that is being started |
permanent | |
- Exceptions
-
bool fesa::Thread::permanent_ |
|
protected |
True if thread is permanent, false otherwise. If true, thread is joinable. Otherwise, thread is detached.
The documentation for this class was generated from the following files: