Public Member Functions | Protected Member Functions

ibrcommon::JoinableThread Class Reference

#include <Thread.h>

Inherits ibrcommon::Thread.

Inherited by dtn::api::Client::AsyncReceiver, dtn::core::AbstractWorker::AbstractWorkerAsync, dtn::core::SQLiteBundleStorage, dtn::daemon::ApiServer::Distributor, dtn::daemon::ClientHandler::Sender, dtn::daemon::IndependentComponent [protected], dtn::net::TCPConvergenceLayer::TCPConnection::Sender, dtn::routing::BaseRouter::ThreadedExtension, ibrcommon::Logger::LogWriter, ibrcommon::SimpleTimer, and ibrcommon::Timer.

Collaboration diagram for ibrcommon::JoinableThread:
Collaboration graph
[legend]

List of all members.

Public Member Functions

virtual ~JoinableThread ()
void join (void)
bool isRunning (void)
void start (int priority=0) throw (ThreadException)
void stop () throw (ThreadException)
void background (void)

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


Constructor & Destructor Documentation

ibrcommon::JoinableThread::JoinableThread ( size_t  size = DEFAULT_STACKSIZE  )  [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 211 of file Thread.cpp.

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

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

Definition at line 216 of file Thread.cpp.

References join().

Here is the call graph for this function:


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

References start().

Here is the call graph for this function:

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

Test if thread is currently running.

Returns:
true while thread is running.

Definition at line 206 of file Thread.h.

void ibrcommon::JoinableThread::join ( void   ) 
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:
priority of child thread.

Definition at line 221 of file Thread.cpp.

References ibrcommon::Thread::exec_thread().

Referenced by background(), dtn::daemon::StatisticLogger::componentUp(), dtn::routing::BaseRouter::componentUp(), dtn::net::DiscoveryAgent::componentUp(), dtn::core::WallClock::componentUp(), and dtn::daemon::IndependentComponent::startup().

Here is the call graph for this function:

void ibrcommon::JoinableThread::stop (  )  throw (ThreadException)

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