libpandac  0.0.0
A library designed for a comm.ai Panda.
Public Member Functions | Protected Member Functions | List of all members
Mogi::Thread Class Referenceabstract

Abstract class, handles a single thread. Features mutual exclusion and pause/resume. More...

#include <thread.h>

Inheritance diagram for Mogi::Thread:
Inheritance graph
Collaboration diagram for Mogi::Thread:
Collaboration graph

Public Member Functions

bool start ()
 Starts the internal thread method. More...
 
void stop ()
 Stops the internal thread method. More...
 
void WaitForInternalThreadToExit ()
 Will wait until the thread has finished.
 
int lock ()
 Performs a mutual exclusion lock. Will halt if locked by another thread, and will resume when the other thread performs an unlock. More...
 
int unlock ()
 Performs a mutual exclusion unlock. Will allow other threads that have been locked to resume. More...
 
void pause ()
 Performs a pause. More...
 
void resume ()
 Resumes the thread from a pause. More...
 
bool running ()
 Returns the state of the thread. More...
 

Protected Member Functions

virtual void entryAction ()
 Called once at the beginning of the thread running. More...
 
virtual void doAction ()
 Continuously called until the thread is commanded to stop. More...
 
virtual void exitAction ()
 Called once when thread is commanded to stop. More...
 
void checkSuspend ()
 Blocks the thread from a pause() call until resume() is called.
 

Detailed Description

Abstract class, handles a single thread. Features mutual exclusion and pause/resume.

Member Function Documentation

virtual void Mogi::Thread::doAction ( )
protectedvirtual

Continuously called until the thread is commanded to stop.

If not defined in the base class, the loop will simply exit. Good practice would be to make this non-blocking.

virtual void Mogi::Thread::entryAction ( )
protectedvirtual

Called once at the beginning of the thread running.

Use this to set up data for the thread.

virtual void Mogi::Thread::exitAction ( )
protectedvirtual

Called once when thread is commanded to stop.

Use this to clean up data in the thread, or place into a stopped state.

int Mogi::Thread::lock ( )

Performs a mutual exclusion lock. Will halt if locked by another thread, and will resume when the other thread performs an unlock.

See also
Thread::unlock
Returns
0 on success, otherwise an error corresponding to pthreads.
void Mogi::Thread::pause ( )

Performs a pause.

See also
Thread::resume.
void Mogi::Thread::resume ( )

Resumes the thread from a pause.

See also
Thread::pause
bool Mogi::Thread::running ( )
inline

Returns the state of the thread.

Returns
true if running
bool Mogi::Thread::start ( )

Starts the internal thread method.

Returns
true if the thread was successfully started, false if there was an error starting the thread.
void Mogi::Thread::stop ( )

Stops the internal thread method.

!

int Mogi::Thread::unlock ( )

Performs a mutual exclusion unlock. Will allow other threads that have been locked to resume.

See also
Thread::lock
Returns
0 on success, otherwise an error corresponding to pthreads.

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