IBR-DTNSuite  0.8
ibrcommon::JoinableThread Class Reference

#include <Thread.h>

Inheritance diagram for ibrcommon::JoinableThread:
Collaboration diagram for ibrcommon::JoinableThread:

List of all members.

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)

Detailed Description

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.

Author:
David Sugar <dyfet@gnutelephony.org>

Definition at line 193 of file Thread.h.


Constructor & Destructor Documentation

Create a joinable thread with a known context stack size.

Parameters:
sizeof stack for thread context or 0 for default.

Definition at line 200 of file Thread.cpp.

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.

Here is the call graph for this function:


Member Function Documentation

bool ibrcommon::JoinableThread::isRunning ( void  ) [inline]

Test if thread is currently running.

Returns:
true while thread is running.

Definition at line 220 of file Thread.h.

References ibrcommon::Thread::_state, and ibrcommon::Thread::THREAD_RUNNING.

Referenced by dtn::core::WallClock::componentUp().

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().

Here is the call graph for this function:

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.

Parameters:
priorityof 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().

Here is the call graph for this function:


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