IBR-DTNSuite
0.10
|
#include <Thread.h>
Public Member Functions | |
virtual | ~JoinableThread ()=0 |
void | join (void) throw (ThreadException) |
bool | isRunning (void) |
void | start (int priority=0) throw (ThreadException) |
void | stop () throw () |
Protected Member Functions | |
JoinableThread (size_t size=DEFAULT_STACKSIZE) | |
Protected Member Functions inherited from ibrcommon::Thread | |
virtual | ~Thread ()=0 |
void | reset () throw (ThreadException) |
virtual void | setup (void) throw () |
virtual void | run (void)=0 throw () |
virtual void | finally (void) throw () |
bool | isFinalized () throw () |
bool | operator== (const ibrcommon::Thread &other) |
Thread (size_t stack=DEFAULT_STACKSIZE) | |
int | kill (int sig) |
void | cancel () throw () |
virtual void | __cancellation ()=0 throw () |
Additional Inherited Members | |
Static Protected Member Functions inherited from ibrcommon::Thread | |
static size_t | getNumberOfProcessors () |
static void | yield (void) |
static void | sleep (time_t timeout) |
static void | concurrency (int level) |
static bool | equal (pthread_t thread1, pthread_t thread2) |
static void * | __execute__ (void *obj) throw () |
A child thread object that may be joined by parent. A child thread is a type of thread in which the parent thread (or process main thread) can then wait for the child thread to complete and then delete the child object. The parent thread can wait for the child thread to complete either by calling join, or performing a "delete" of the derived child object. In either case the parent thread will suspend execution until the child thread exits.
|
protected |
Create a joinable thread with a known context stack size.
size | of stack for thread context or 0 for default. |
Definition at line 210 of file Thread.cpp.
|
pure virtual |
Delete child thread. Parent thread suspends until child thread run method completes or child thread calls it's exit method.
Definition at line 215 of file Thread.cpp.
References ibrcommon::Thread::_state, ibrcommon::ThreadsafeState< T >::get(), join(), and ibrcommon::Thread::THREAD_FINALIZED.
|
inline |
Test if thread is currently running.
Definition at line 221 of file Thread.h.
References ibrcommon::Thread::_state, and ibrcommon::Thread::THREAD_RUNNING.
Referenced by dtn::core::WallClock::componentUp().
void ibrcommon::JoinableThread::join | ( | void | ) | throw (ThreadException) |
Join thread with parent. Calling from a child thread to exit is now depreciated behavior and in the future will not be supported. Threads should always return through their run() method.
Definition at line 312 of file Thread.cpp.
References ibrcommon::Thread::_state, ibrcommon::Thread::equal(), ibrcommon::ThreadsafeState< T >::lock(), ibrcommon::Thread::THREAD_CREATED, ibrcommon::Thread::THREAD_FINALIZED, ibrcommon::Thread::THREAD_JOINABLE, ibrcommon::Thread::tid, and ibrcommon::ThreadsafeState< T >::Locked::wait().
Referenced by dtn::routing::StaticRoutingExtension::componentDown(), dtn::routing::NeighborRoutingExtension::componentDown(), dtn::routing::FloodRoutingExtension::componentDown(), dtn::routing::EpidemicRoutingExtension::componentDown(), dtn::routing::ProphetRoutingExtension::componentDown(), dtn::net::IPNDAgent::componentDown(), dtn::core::FragmentManager::componentDown(), dtn::net::UDPConvergenceLayer::componentDown(), dtn::net::LOWPANConvergenceLayer::componentDown(), dtn::storage::SQLiteBundleStorage::componentDown(), dtn::storage::SimpleBundleStorage::componentDown(), dtn::net::HTTPConvergenceLayer::componentRun(), dtn::net::LOWPANConnection::finally(), dtn::api::ApiServer::~ApiServer(), dtn::net::DatagramConvergenceLayer::~DatagramConvergenceLayer(), dtn::storage::DataStorage::~DataStorage(), dtn::net::DownloadThread::~DownloadThread(), dtn::routing::EpidemicRoutingExtension::~EpidemicRoutingExtension(), dtn::net::FileMonitor::~FileMonitor(), dtn::routing::FloodRoutingExtension::~FloodRoutingExtension(), dtn::daemon::IndependentComponent::~IndependentComponent(), ~JoinableThread(), dtn::routing::NeighborRoutingExtension::~NeighborRoutingExtension(), dtn::routing::ProphetRoutingExtension::~ProphetRoutingExtension(), dtn::routing::StaticRoutingExtension::~StaticRoutingExtension(), dtn::net::TCPConvergenceLayer::~TCPConvergenceLayer(), ibrcommon::Timer::~Timer(), and dtn::net::WifiP2PManager::~WifiP2PManager().
void ibrcommon::JoinableThread::start | ( | int | priority = 0 | ) | throw (ThreadException) |
Start execution of child context. This must be called after the child object is created (perhaps with "new") and before it can be joined. This method actually begins the new thread context, which then calls the object's run method. Optionally raise the priority of the thread when it starts under realtime priority.
priority | of child thread. |
Definition at line 228 of file Thread.cpp.
References ibrcommon::Thread::__execute__().
Referenced by dtn::net::HTTPConvergenceLayer::componentRun(), dtn::routing::StaticRoutingExtension::componentUp(), dtn::routing::NeighborRoutingExtension::componentUp(), dtn::routing::FloodRoutingExtension::componentUp(), dtn::routing::EpidemicRoutingExtension::componentUp(), dtn::core::WallClock::componentUp(), dtn::routing::ProphetRoutingExtension::componentUp(), dtn::storage::SimpleBundleStorage::componentUp(), and dtn::net::LOWPANConnection::setup().
void ibrcommon::JoinableThread::stop | ( | ) | throw () |
Stop the execution of child context.
Definition at line 307 of file Thread.cpp.
References ibrcommon::Thread::cancel().
Referenced by dtn::net::LOWPANConnection::__cancellation(), dtn::routing::StaticRoutingExtension::componentDown(), dtn::routing::NeighborRoutingExtension::componentDown(), dtn::routing::FloodRoutingExtension::componentDown(), dtn::routing::EpidemicRoutingExtension::componentDown(), dtn::routing::ProphetRoutingExtension::componentDown(), dtn::net::IPNDAgent::componentDown(), dtn::core::FragmentManager::componentDown(), dtn::net::UDPConvergenceLayer::componentDown(), dtn::net::LOWPANConvergenceLayer::componentDown(), dtn::storage::SQLiteBundleStorage::componentDown(), dtn::storage::SimpleBundleStorage::componentDown(), dtn::net::LOWPANConnection::finally(), dtn::api::ApiServer::~ApiServer(), dtn::routing::ProphetRoutingExtension::~ProphetRoutingExtension(), and ibrcommon::Timer::~Timer().