ibrcommon::JoinableThread Class Reference

#include <Thread.h>

Inheritance diagram for ibrcommon::JoinableThread:
ibrcommon::Thread dtn::daemon::ClientHandler dtn::daemon::IndependentComponent dtn::routing::BaseRouter::ThreadedExtension ibrcommon::MultiTimer ibrcommon::SimpleTimer ibrcommon::Timer dtn::core::SimpleBundleStorage dtn::core::SQLiteBundleStorage dtn::core::WallClock dtn::net::DiscoveryAgent dtn::net::GenericServer< T > dtn::net::HTTPConvergenceLayer dtn::net::LOWPANConvergenceLayer dtn::net::UDPConvergenceLayer dtn::net::GenericServer< ClientHandler > dtn::net::GenericServer< TCPConvergenceLayer::TCPConnection > dtn::routing::EpidemicRoutingExtension dtn::routing::NeighborRoutingExtension

List of all members.

Public Member Functions

bool isRunning (void)
void start (int priority=0)
void background (void)
void waitFor ()

Protected Member Functions

 JoinableThread (size_t size=0)
virtual ~JoinableThread ()
void join (void)

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 120 of file Thread.h.


Constructor & Destructor Documentation

ibrcommon::JoinableThread::JoinableThread ( size_t  size = 0  )  [protected]

Create a joinable thread with a known context stack size.

Parameters:
size of stack for thread context or 0 for default.

Definition at line 84 of file Thread.cpp.

References ibrcommon::Thread::stack.

ibrcommon::JoinableThread::~JoinableThread (  )  [protected, virtual]

Delete child thread. Parent thread suspends until child thread run method completes or child thread calls it's exit method.

Definition at line 90 of file Thread.cpp.

References join().


Member Function Documentation

void ibrcommon::JoinableThread::background ( void   )  [inline]

Start execution of child context as background thread. This is assumed to be off main thread, with a priority lowered by one.

Definition at line 167 of file Thread.h.

References start().

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

Test if thread is currently running.

Returns:
true while thread is running.

Reimplemented in dtn::daemon::IndependentComponent.

Definition at line 150 of file Thread.h.

void ibrcommon::JoinableThread::join ( void   )  [protected]
void ibrcommon::JoinableThread::start ( int  priority = 0  ) 

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:
priority of child thread.

Definition at line 95 of file Thread.cpp.

References ibrcommon::Thread::priority, ibrcommon::Thread::stack, and ibrcommon::Thread::tid.

Referenced by dtn::daemon::ApiServer::accept(), background(), dtn::daemon::StatisticLogger::componentUp(), dtn::routing::BaseRouter::componentUp(), and dtn::daemon::IndependentComponent::startup().

void ibrcommon::JoinableThread::waitFor (  ) 

Definition at line 144 of file Thread.cpp.

References join().


The documentation for this class was generated from the following files:
Generated on Mon Aug 23 08:13:03 2010 for IBR-DTNSuite by  doxygen 1.6.3