FeeServer::Thread Class Reference
[Threading classes]

#include <feeserver/fee_thread.hh>

Inheritance diagram for FeeServer::Thread:

Inheritance graph
[legend]

List of all members.


Detailed Description

Class representing a thread. The user should overload the function operator member function (operator()) to do the thread job. Provides member function for cancelling, joining, and so on.

Public Types

enum  Return {
  Success, Missing, BadThread, BadValue,
  DeadLock, Running, NotCurrent, NotRunning
}

Public Member Functions

 Thread (const std::string &name=std::string())
virtual ~Thread ()
Return Run ()
Return Run (const Attributes &a)
virtual void * operator() ()=0
void Stop (void *ret=0)
Return Detach ()
Return Cancel ()
void TestCancel ()
Return EnableCancel (bool enable=true)
Return AsyncCancel (bool async=true)
Return Join (void *&ret)
Return Join ()
bool IsCurrent () const
bool IsRunning () const
bool operator== (const Thread &other) const

Protected Member Functions

virtual void HandleCleanup ()

Static Protected Member Functions

static Return HandleReturn (int ret)

Protected Attributes

std::string _name
pthread_t _thread
bool _is_running

Friends

class ThreadManager
void * fee_thread_launcher (void *arg) throw ()
void fee_thread_cleanup (void *arg)

Classes

class  Attributes
 Thread attributes. More...

Member Enumeration Documentation

Enumerator:
Success  Success
Missing  Missing system resources
BadThread  No such thread
BadValue  Operation not meaningful for thread
DeadLock  Would dead-lock
Running  Thread is already running
NotCurrent  Calling thread isn't this thread
NotRunning  Calling thread isn't running


Constructor & Destructor Documentation

FeeServer::Thread::Thread ( const std::string &  name = std::string()  ) 

Constructor.

FeeServer::Thread::~Thread (  )  [virtual]

Destructor


Member Function Documentation

FeeServer::Thread::Return FeeServer::Thread::Run (  ) 

Start the thread.

Returns:
true on success, false otherwise

FeeServer::Thread::Return FeeServer::Thread::Run ( const Attributes a  ) 

Start the thread.

Returns:
true on success, false otherwise

virtual void* FeeServer::Thread::operator() (  )  [pure virtual]

Users should override this to define the thread function to be executed.

Returns:
Pointer to something, optionally NULL.

Implemented in FeeServer::ControlEngine, FeeServer::IssueThread, FeeServer::MonitorThread, and FeeServer::MessageWatchdog.

void FeeServer::Thread::Stop ( void *  ret = 0  ) 

Stop this thread.

Parameters:
ret Address of possible return value

FeeServer::Thread::Return FeeServer::Thread::Detach (  ) 

Detach this thread

Returns:
true on success, false otherwise

FeeServer::Thread::Return FeeServer::Thread::Cancel (  ) 

Cancel this thread.

Returns:
true on success, false otherwise

void FeeServer::Thread::TestCancel (  ) 

Test for cancellation of this thread

FeeServer::Thread::Return FeeServer::Thread::EnableCancel ( bool  enable = true  ) 

Enable/Disable cancellation of this thread. This must be executed in the corresponding thread (i.e., in the function operator, or member functions called from there) to have any effect.

Parameters:
enable If true, enable cancellation, otherwise disable cancellation.
Returns:
true on success, false otherwise

FeeServer::Thread::Return FeeServer::Thread::AsyncCancel ( bool  async = true  ) 

Set the cancellation type. This must be executed in the corresponding thread (i.e., in the function operator, or member functions called from there) to have any effect.

Parameters:
async If true, cancel as soon as possible, otherwise wait for an (explicit) cancellation point.
Returns:
true on success, false otherwise

FeeServer::Thread::Return FeeServer::Thread::Join ( void *&  ret  ) 

Join calling thread to this thread. This must not be executed in the associated thread, or it will have no effect (false is returned).

Parameters:
ret Reference to pointer where to store the return value of this thread.
Returns:
true on success, false other wise

FeeServer::Thread::Return FeeServer::Thread::Join (  ) 

Like the member function above, except that there's no return parameter.

Returns:
true on success, false other wise

bool FeeServer::Thread::IsCurrent (  )  const

Test if the thread of this object is the current thread

Returns:
true if we're in our thread.

bool FeeServer::Thread::IsRunning (  )  const [inline]

Check if this thread is running

Returns:
true if the thread is running.

bool FeeServer::Thread::operator== ( const Thread other  )  const

Comparison operator

void FeeServer::Thread::HandleCleanup (  )  [protected, virtual]

Clean up handler

FeeServer::Thread::Return FeeServer::Thread::HandleReturn ( int  ret  )  [static, protected]

Handle return values


Friends And Related Function Documentation

friend class ThreadManager [friend]

Manager is friend

void* fee_thread_launcher ( void *  arg  )  throw () [friend]

Friend function

Trampoline function

void fee_thread_cleanup ( void *  arg  )  [friend]

Friend function

Clean-up handler


Member Data Documentation

std::string FeeServer::Thread::_name [protected]

Name oe the thread

pthread_t FeeServer::Thread::_thread [protected]

Thread object

Whether we're running or not.


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

Generated on Thu Jun 26 17:02:42 2008 for FeeServer++ 0.9 by  doxygen 1.5.6