#include <Thread.h>
Public Member Functions | |
Thread () | |
Constructor. It starts the thread and resets the pointer association. | |
~Thread () | |
Destructor. It tells the thread to kill itself, wait its dead and return. | |
void | setWorkObject (void *wO) |
void | setWork (void(*w)(void *)) |
void | setWorkClean (void(*wC)(void *)) |
void | setSleepTime (Time sleepT) |
*void | work () |
void | workClean () |
void | startWork () |
void | stopWork () |
void | liveCycle () |
Protected Attributes | |
pthread_t | _tid |
bool | _live |
bool | _doWork |
bool | _stopWork |
bool | _dirty |
Time | _sleepTime |
void * | _workObject |
void(* | _work )(void *) |
void(* | _workClean )(void *) |
Static Protected Attributes | |
static const int | THREAD_SLEEP_USECS = 100000 |
Thread::Thread | ( | ) |
Constructor. It starts the thread and resets the pointer association.
Thread::~Thread | ( | ) |
Destructor. It tells the thread to kill itself, wait its dead and return.
void MipBaselib::Thread::setWorkObject | ( | void * | wO | ) | [inline] |
Sets the pointer to the object that must be passed to your work function.
wO | Pointer to the object that wil be passed to work and workClean. |
void MipBaselib::Thread::setWork | ( | void(*)(void *) | w | ) | [inline] |
Sets the pointer to to your work routine.
wC | Pointer to the function work the work routine must be a state machine. |
void MipBaselib::Thread::setWorkClean | ( | void(*)(void *) | wC | ) | [inline] |
Sets the pointer to your workClean routine.
wC | Pointer to the function workClean. |
void MipBaselib::Thread::setSleepTime | ( | Time | sleepT | ) | [inline] |
Sets the pointer to your workClean routine.
sleepT | Sleep time between two consecutive work() calls. |
* void MipBaselib::Thread::work | ( | ) | [inline] |
Calls the *_work routine set by setWork(), passing to it the work object which was been set in setWorkObject
It will be repeatly called after the startWork() method is called, and until the stopWork() method is called.
void MipBaselib::Thread::workClean | ( | ) | [inline] |
Calls the *_workClean routine sets by setWorkClean(), passing to it the work object set in setWorkObject.
It will be called immediatly after the stopWork() (only if at least a work() is called) to perform the exiting work, (you may think at a communication closing, as an example).
void MipBaselib::Thread::startWork | ( | ) | [inline] |
This is a button that enables the work.
void MipBaselib::Thread::stopWork | ( | ) | [inline] |
This is a button that disables the work and calls workClean.
void Thread::liveCycle | ( | ) |
This is the main thread cycle, it should be private, hence don't care about it.
pthread_t MipBaselib::Thread::_tid [protected] |
Thread id.
bool MipBaselib::Thread::_live [protected] |
Button: if true the thread live, otherwise the thread exit.
bool MipBaselib::Thread::_doWork [protected] |
Button, if true the thread do the work, otherwise it do nothing.
bool MipBaselib::Thread::_stopWork [protected] |
Todo.
bool MipBaselib::Thread::_dirty [protected] |
Button, if true the thread do the workCleaning othewise no.
Time MipBaselib::Thread::_sleepTime [protected] |
Time the trhead sleep in every case (work don't work).
const int MipBaselib::Thread::THREAD_SLEEP_USECS = 100000 [static, protected] |
void* MipBaselib::Thread::_workObject [protected] |
Pointer to the object that must be passed to your work function.
void(* MipBaselib::Thread::_work)(void *) [protected] |
Pointer to to your work funtion.
void(* MipBaselib::Thread::_workClean)(void *) [protected] |
Pointer to your workClean function.