#include <feeserver/fee_thread.hh>
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... |
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 |
FeeServer::Thread::Thread | ( | const std::string & | name = std::string() |
) |
Constructor.
FeeServer::Thread::~Thread | ( | ) | [virtual] |
Destructor
FeeServer::Thread::Return FeeServer::Thread::Run | ( | ) |
Start the thread.
FeeServer::Thread::Return FeeServer::Thread::Run | ( | const Attributes & | a | ) |
Start the thread.
virtual void* FeeServer::Thread::operator() | ( | ) | [pure virtual] |
Users should override this to define the thread function to be executed.
Implemented in FeeServer::ControlEngine, FeeServer::IssueThread, FeeServer::MonitorThread, and FeeServer::MessageWatchdog.
void FeeServer::Thread::Stop | ( | void * | ret = 0 |
) |
Stop this thread.
ret | Address of possible return value |
FeeServer::Thread::Return FeeServer::Thread::Detach | ( | ) |
Detach this thread
FeeServer::Thread::Return FeeServer::Thread::Cancel | ( | ) |
Cancel this thread.
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.
enable | If true, enable cancellation, otherwise disable cancellation. |
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.
async | If true, cancel as soon as possible, otherwise wait for an (explicit) cancellation point. |
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).
ret | Reference to pointer where to store the return value of this thread. |
FeeServer::Thread::Return FeeServer::Thread::Join | ( | ) |
Like the member function above, except that there's no return parameter.
bool FeeServer::Thread::IsCurrent | ( | ) | const |
Test if the thread of this object is the current thread
bool FeeServer::Thread::IsRunning | ( | ) | const [inline] |
Check if this 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
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
std::string FeeServer::Thread::_name [protected] |
Name oe the thread
pthread_t FeeServer::Thread::_thread [protected] |
Thread object
bool FeeServer::Thread::_is_running [protected] |
Whether we're running or not.