#include <Thread.h>
Inherited by ibrcommon::DetachedThread [protected], and ibrcommon::JoinableThread [protected].

Classes | |
| class | CancelProtector |
Public Member Functions | |
| virtual void | run (void)=0 |
| virtual void | finally (void) |
| virtual | ~Thread () |
| void | detach (void) |
| bool | operator== (const ibrcommon::Thread &other) |
| void | ready () |
| void | waitready () |
Static Public Member Functions | |
| static void | yield (void) |
| static void | sleep (size_t timeout) |
| static void | exit (void) |
| static void | concurrency (int level) |
| static int | enableCancel (int &state) |
| static int | disableCancel (int &state) |
| static int | restoreCancel (const int &state) |
Public Attributes | |
| const bool | __delete_on_exit |
Protected Member Functions | |
| Thread (size_t stack=DEFAULT_STACKSIZE, bool delete_on_exit=false) | |
| int | kill (int sig) |
| void | cancel () throw (ThreadException) |
| virtual bool | __cancellation () |
| int | setCancel (bool val) |
Static Protected Member Functions | |
| static void | testcancel () |
| static bool | equal (pthread_t thread1, pthread_t thread2) |
| static void * | exec_thread (void *obj) |
Protected Attributes | |
| pthread_t | tid |
| size_t | stack |
| int | priority |
| pthread_attr_t | attr |
| ibrcommon::Conditional | _readycond |
| bool | _ready |
An abstract class for defining classes that operate as a thread. A derived thread class has a run method that is invoked with the newly created thread context, and can use the derived object to store all member data that needs to be associated with that context. This means the derived object can safely hold thread-specific data that is managed with the life of the object, rather than having to use the clumsy thread-specific data management and access functions found in thread support libraries.
Definition at line 41 of file Thread.h.
| ibrcommon::Thread::Thread | ( | size_t | stack = DEFAULT_STACKSIZE, |
|
| bool | delete_on_exit = false | |||
| ) | [protected] |
Create a thread object that will have a preset stack size. If 0 is used, then the stack size is os defined/default.
| stack | size to use or 0 for default. |
Definition at line 63 of file Thread.cpp.
References attr.
| ibrcommon::Thread::~Thread | ( | ) | [virtual] |
Destroy thread object, thread-specific data, and execution context.
Definition at line 106 of file Thread.cpp.
References attr.
| virtual bool ibrcommon::Thread::__cancellation | ( | ) | [inline, protected, virtual] |
Reimplemented in ibrcommon::Timer, ibrcommon::SimpleTimer, dtn::daemon::IndependentComponent, dtn::core::SQLiteBundleStorage, dtn::net::GenericServer< T >, dtn::net::HTTPConvergenceLayer, dtn::routing::FloodRoutingExtension, dtn::routing::NeighborRoutingExtension, and dtn::net::GenericServer< TCPConvergenceLayer::TCPConnection >.
Definition at line 144 of file Thread.h.
Referenced by cancel().
| void ibrcommon::Thread::cancel | ( | ) | throw (ThreadException) [protected] |
Cancel the running thread context.
Definition at line 127 of file Thread.cpp.
References __cancellation(), kill(), and tid.
Referenced by ibrcommon::DetachedThread::stop(), and ibrcommon::JoinableThread::stop().

| void ibrcommon::Thread::concurrency | ( | int | level | ) | [static] |
Set concurrency level of process. This is essentially a portable wrapper for pthread_setconcurrency.
Definition at line 85 of file Thread.cpp.
| void ibrcommon::Thread::detach | ( | void | ) |
Definition at line 111 of file Thread.cpp.
References tid.
| int ibrcommon::Thread::disableCancel | ( | int & | state | ) | [static] |
Definition at line 149 of file Thread.cpp.
Referenced by ibrcommon::Thread::CancelProtector::CancelProtector().
| int ibrcommon::Thread::enableCancel | ( | int & | state | ) | [static] |
Definition at line 144 of file Thread.cpp.
Referenced by ibrcommon::Thread::CancelProtector::CancelProtector().
| bool ibrcommon::Thread::equal | ( | pthread_t | thread1, | |
| pthread_t | thread2 | |||
| ) | [static, protected] |
Determine if two thread identifiers refer to the same thread.
| thread1 | to test. | |
| thread2 | to test. |
Definition at line 173 of file Thread.cpp.
Referenced by ibrcommon::JoinableThread::join(), and operator==().
| void * ibrcommon::Thread::exec_thread | ( | void * | obj | ) | [static, protected] |
static execute thread method
Definition at line 36 of file Thread.cpp.
References exit(), IBRCOMMON_LOGGER_DEBUG, ready(), and run().
Referenced by ibrcommon::DetachedThread::start(), and ibrcommon::JoinableThread::start().

| void ibrcommon::Thread::exit | ( | void | ) | [static] |
Exit the thread context.
Reimplemented in ibrcommon::DetachedThread.
Definition at line 116 of file Thread.cpp.
Referenced by exec_thread(), and ibrcommon::JoinableThread::join().
| virtual void ibrcommon::Thread::finally | ( | void | ) | [inline, virtual] |
Reimplemented in dtn::daemon::ClientHandler, and dtn::net::TCPConvergenceLayer::TCPConnection.
Definition at line 84 of file Thread.h.
Referenced by ibrcommon::ThreadFinalizer::~ThreadFinalizer().
| int ibrcommon::Thread::kill | ( | int | sig | ) | [protected] |
| bool ibrcommon::Thread::operator== | ( | const ibrcommon::Thread & | other | ) | [inline] |
| void ibrcommon::Thread::ready | ( | ) |
Indicates that the run() method is up
Definition at line 178 of file Thread.cpp.
References _ready, _readycond, and ibrcommon::Conditional::signal().
Referenced by exec_thread().

| int ibrcommon::Thread::restoreCancel | ( | const int & | state | ) | [static] |
Definition at line 154 of file Thread.cpp.
Referenced by ibrcommon::Thread::CancelProtector::~CancelProtector().
| virtual void ibrcommon::Thread::run | ( | void | ) | [pure virtual] |
Abstract interface for thread context run method.
Implemented in ibrcommon::Timer, ibrcommon::SimpleTimer, dtn::daemon::ClientHandler, dtn::daemon::IndependentComponent, dtn::core::SQLiteBundleStorage, dtn::net::TCPConvergenceLayer::TCPConnection, dtn::routing::FloodRoutingExtension, and dtn::routing::NeighborRoutingExtension.
Referenced by exec_thread().
| int ibrcommon::Thread::setCancel | ( | bool | val | ) | [protected] |
Definition at line 159 of file Thread.cpp.
| void ibrcommon::Thread::sleep | ( | size_t | timeout | ) | [static] |
Sleep current thread for a specified time period.
| timeout | to sleep for in milliseconds. |
Definition at line 92 of file Thread.cpp.
| void ibrcommon::Thread::testcancel | ( | ) | [static, protected] |
Definition at line 80 of file Thread.cpp.
| void ibrcommon::Thread::waitready | ( | ) |
Definition at line 185 of file Thread.cpp.
References _ready, _readycond, and ibrcommon::Conditional::wait().

| void ibrcommon::Thread::yield | ( | void | ) | [static] |
Yield execution context of the current thread. This is a static and may be used anywhere.
Definition at line 69 of file Thread.cpp.
Referenced by dtn::net::UDPConvergenceLayer::componentRun(), dtn::net::LOWPANConvergenceLayer::componentRun(), dtn::net::IPNDAgent::componentRun(), dtn::net::HTTPConvergenceLayer::componentRun(), dtn::net::GenericServer< TCPConvergenceLayer::TCPConnection >::componentRun(), dtn::core::SimpleBundleStorage::componentRun(), dtn::daemon::ApiServer::componentRun(), ibrcommon::SimpleTimer::run(), ibrcommon::Timer::run(), dtn::routing::NeighborRoutingExtension::run(), dtn::routing::FloodRoutingExtension::run(), dtn::routing::EpidemicRoutingExtension::run(), dtn::net::TCPConvergenceLayer::TCPConnection::run(), and dtn::daemon::ClientHandler::run().
| const bool ibrcommon::Thread::__delete_on_exit |
Definition at line 65 of file Thread.h.
Referenced by ibrcommon::ThreadFinalizer::~ThreadFinalizer().
bool ibrcommon::Thread::_ready [protected] |
Definition at line 55 of file Thread.h.
Referenced by ready(), and waitready().
ibrcommon::Conditional ibrcommon::Thread::_readycond [protected] |
Definition at line 54 of file Thread.h.
Referenced by ready(), and waitready().
pthread_attr_t ibrcommon::Thread::attr [protected] |
int ibrcommon::Thread::priority [protected] |
size_t ibrcommon::Thread::stack [protected] |
Definition at line 50 of file Thread.h.
Referenced by ibrcommon::DetachedThread::DetachedThread().
pthread_t ibrcommon::Thread::tid [protected] |
Definition at line 49 of file Thread.h.
Referenced by cancel(), detach(), ibrcommon::JoinableThread::join(), kill(), and operator==().
1.7.1