MipBaselib::Thread Class Reference

#include <Thread.h>

List of all members.

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


Detailed Description

Examples:

exampleThread.cpp.


Constructor & Destructor Documentation

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.


Member Function Documentation

void MipBaselib::Thread::setWorkObject ( void *  wO  )  [inline]

Sets the pointer to the object that must be passed to your work function.

Parameters:
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.

Parameters:
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.

Parameters:
wC Pointer to the function workClean.
Note:
The workClean routine is a cleaning routine, it is expected to be a batch routine.

void MipBaselib::Thread::setSleepTime ( Time  sleepT  )  [inline]

Sets the pointer to your workClean routine.

Parameters:
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.

Note:
Could be wrapped in the including class (to change its name).

void MipBaselib::Thread::stopWork (  )  [inline]

This is a button that disables the work and calls workClean.

Note:
Could be wrapped in the including class (to change its name).

void Thread::liveCycle (  ) 

This is the main thread cycle, it should be private, hence don't care about it.


Member Data Documentation

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.

Todo.

bool MipBaselib::Thread::_dirty [protected]

Button, if true the thread do the workCleaning othewise no.

Time the trhead sleep in every case (work don't work).

const int MipBaselib::Thread::THREAD_SLEEP_USECS = 100000 [static, 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.


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

Generated on Mon Feb 20 07:01:12 2017 for MIP by  doxygen 1.5.6