automotive-message-broker  0.14.803
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
Public Member Functions | Protected Member Functions | List of all members
CUtil::Thread Class Referenceabstract

Encapsulation of the POSIX thread. More...

#include <thread.h>

Inheritance diagram for CUtil::Thread:
CANSocketReader

Public Member Functions

virtual void run ()=0
 
virtual bool start ()
 
bool setPriority (int priority)
 
virtual void stop ()
 
bool restart ()
 

Protected Member Functions

bool isRunnable (long miliseconds=0)
 

Detailed Description

Encapsulation of the POSIX thread.

Supports starting, stopping, restarting and thread status checking.

Member Function Documentation

CUtil::Thread::isRunnable ( long  miliseconds = 0)
protected

Gets runnable status of current thread. Sleeps calling thread for a specified time.

Parameters
milisecondsTime in miliseconds. 0 means no sleep.
Returns
True if thread should still run.

Example

void MyCustomThread::run()
{
while(isRunnable(1000)) { // execute some op once per second. Exits thread if stop() was called.
...
}
}
CUtil::Thread::restart ( )
inline

Restarts the thread.

Returns
True if thread was started again
CUtil::Thread::run ( )
pure virtual

Method to be executed in this thread. Has to be overwritten.

CUtil::Thread::start ( )
virtual

Starts the thread

Returns
True if thread was started

Reimplemented in CANSocketReader.

CUtil::Thread::stop ( )
virtual

Stops the thread

Reimplemented in CANSocketReader.


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