ThreadObj Class Reference

Thread. More...

#include <thread_obj.h>

Inheritance diagram for ThreadObj:

Inheritance graph
[legend]
Collaboration diagram for ThreadObj:

Collaboration graph
[legend]

List of all members.

Public Member Functions

 ThreadObj (std::string name)
 Constructor.
virtual ~ThreadObj ()
void Start ()
 Start the Main method in a separate thread.
void Stop ()
 Ask the thread to stop.
void Kill ()
 Kill the thread.
virtual void OnStart ()
 Method called when a call to Start is done.
virtual void OnStop ()
 Method called when a call to Stop is done.
bool GetStopped ()
 Check whether the object has already been started.

Static Public Member Functions

static void * StartThread (void *)

Public Attributes

pthread_t id
std::string name

Protected Member Functions

virtual void Main ()=0
 Main method executed in a separate thread.
bool GetAskStop ()
 Check whether the thread was asked to stop (by a user request).


Detailed Description

Thread.

Thread

Definition at line 11 of file thread_obj.h.


Constructor & Destructor Documentation

ThreadObj::ThreadObj ( std::string  name  ) 

Constructor.

Parameters:
name std::string to specify the name of the thread. This parameter is used as a prefix to loglines.

Definition at line 18 of file thread_obj.cpp.

ThreadObj::~ThreadObj (  )  [virtual]

Definition at line 28 of file thread_obj.cpp.


Member Function Documentation

bool ThreadObj::GetAskStop (  )  [protected]

Check whether the thread was asked to stop (by a user request).

Returns:
true when a call to Stop was done, and false when a call to Stop has not yet been done.

Definition at line 109 of file thread_obj.cpp.

bool ThreadObj::GetStopped (  ) 

Check whether the object has already been started.

Returns:
false when the thread has already started, false when it ahs been stopped, killed or terminated by exiting the Main method.

Definition at line 117 of file thread_obj.cpp.

void ThreadObj::Kill (  ) 

Kill the thread.

The execution of the Main method is interrupted.

Definition at line 73 of file thread_obj.cpp.

virtual void ThreadObj::Main (  )  [protected, pure virtual]

Main method executed in a separate thread.

This method is executed in a separate thread when a call to Start is done.

Implemented in FastLoopThreadObj, and LoopThreadObj.

virtual void ThreadObj::OnStart (  )  [inline, virtual]

Method called when a call to Start is done.

Method called from the thread newly created before the Main method is called.

Reimplemented in FastLoopThreadObj.

Definition at line 63 of file thread_obj.h.

virtual void ThreadObj::OnStop (  )  [inline, virtual]

Method called when a call to Stop is done.

Method called from the thread that is about to exit, after the Main method exited. This method is not called when the thread is stopped with the Kill method.

Reimplemented in FastLoopThreadObj, and Server< A >.

Definition at line 70 of file thread_obj.h.

void ThreadObj::Start (  ) 

Start the Main method in a separate thread.

Definition at line 37 of file thread_obj.cpp.

void * ThreadObj::StartThread ( void *  arg  )  [static]

Definition at line 50 of file thread_obj.cpp.

void ThreadObj::Stop (  ) 

Ask the thread to stop.

In order to use this method, the Main method has to implement cancelation by checking the value returned by GetAskStop.

Definition at line 125 of file thread_obj.cpp.


Member Data Documentation

pthread_t ThreadObj::id

Definition at line 33 of file thread_obj.h.

std::string ThreadObj::name

Definition at line 34 of file thread_obj.h.


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

Generated on Sun Oct 10 19:10:05 2010 for libldsw by  doxygen 1.5.8