IBR-DTNSuite
0.8
|
#include <Thread.h>
Public Member Functions | |
virtual | ~JoinableThread ()=0 |
void | join (void) |
bool | isRunning (void) |
void | start (int priority=0) throw (ThreadException) |
void | stop () throw (ThreadException) |
Protected Member Functions | |
JoinableThread (size_t size=DEFAULT_STACKSIZE) |
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.
ibrcommon::JoinableThread::JoinableThread | ( | size_t | size = DEFAULT_STACKSIZE | ) | [protected] |
Create a joinable thread with a known context stack size.
size | of stack for thread context or 0 for default. |
Definition at line 200 of file Thread.cpp.
ibrcommon::JoinableThread::~JoinableThread | ( | ) | [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 205 of file Thread.cpp.
References ibrcommon::Thread::_state, ibrcommon::ThreadsafeState< T >::get(), join(), ibrcommon::Thread::THREAD_ERROR, and ibrcommon::Thread::THREAD_JOINED.
bool ibrcommon::JoinableThread::isRunning | ( | void | ) | [inline] |
Test if thread is currently running.
Definition at line 220 of file Thread.h.
References ibrcommon::Thread::_state, and ibrcommon::Thread::THREAD_RUNNING.
Referenced by dtn::core::WallClock::componentUp().
void ibrcommon::JoinableThread::join | ( | void | ) |
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 297 of file Thread.cpp.
References ibrcommon::Thread::_state, ibrcommon::Thread::equal(), ibrcommon::Thread::exit(), IBRCOMMON_LOGGER, IBRCOMMON_LOGGER_ENDL, ibrcommon::ThreadsafeState< T >::lock(), ibrcommon::Thread::THREAD_ERROR, ibrcommon::Thread::THREAD_FINALIZED, ibrcommon::Thread::THREAD_INITIALIZED, ibrcommon::Thread::THREAD_JOINED, ibrcommon::Thread::tid, and ibrcommon::ThreadsafeState< T >::Locked::wait().
Referenced by dtn::net::IPNDAgent::componentDown(), dtn::net::UDPConvergenceLayer::componentDown(), dtn::net::LOWPANConvergenceLayer::componentDown(), dtn::storage::SimpleBundleStorage::componentDown(), dtn::routing::BaseRouter::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(), ibrcommon::NetLinkManager::~NetLinkManager(), dtn::routing::ProphetRoutingExtension::~ProphetRoutingExtension(), dtn::storage::SQLiteBundleStorage::~SQLiteBundleStorage(), dtn::routing::StaticRoutingExtension::~StaticRoutingExtension(), and ibrcommon::Timer::~Timer().
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 218 of file Thread.cpp.
References ibrcommon::Thread::exec_thread().
Referenced by dtn::net::HTTPConvergenceLayer::componentRun(), dtn::core::WallClock::componentUp(), dtn::daemon::StatisticLogger::componentUp(), dtn::storage::SimpleBundleStorage::componentUp(), dtn::routing::BaseRouter::componentUp(), dtn::net::LOWPANConnection::setup(), and dtn::daemon::IndependentComponent::startup().
void ibrcommon::JoinableThread::stop | ( | ) | throw (ThreadException) |
Stop the execution of child context.
Definition at line 285 of file Thread.cpp.
References ibrcommon::Thread::cancel().
Referenced by dtn::net::LOWPANConnection::__cancellation(), dtn::net::IPNDAgent::componentDown(), dtn::net::UDPConvergenceLayer::componentDown(), dtn::net::LOWPANConvergenceLayer::componentDown(), dtn::storage::SimpleBundleStorage::componentDown(), dtn::routing::BaseRouter::componentDown(), dtn::net::LOWPANConnection::finally(), dtn::daemon::IndependentComponent::terminate(), dtn::api::ApiServer::~ApiServer(), dtn::routing::EpidemicRoutingExtension::~EpidemicRoutingExtension(), dtn::routing::FloodRoutingExtension::~FloodRoutingExtension(), dtn::routing::NeighborRoutingExtension::~NeighborRoutingExtension(), ibrcommon::NetLinkManager::~NetLinkManager(), dtn::routing::ProphetRoutingExtension::~ProphetRoutingExtension(), dtn::storage::SQLiteBundleStorage::~SQLiteBundleStorage(), dtn::routing::StaticRoutingExtension::~StaticRoutingExtension(), and ibrcommon::Timer::~Timer().