Main Page | Class Hierarchy | Alphabetical List | Compound List | File List | Compound Members | File Members | Related Pages

LOW_thread_thread Class Reference

Abstract base class for threads. More...

#include <LOW_thread_thread.h>

Inheritance diagram for LOW_thread_thread:

Inheritance graph
[legend]
List of all members.

Public Member Functions

 class_DERIVE_FROM_EXCEPTION (thread_thread_error, LOW_exception)
 Exception base class for all exceptions thrown by LOW_thread_thread.

 class_DERIVE_FROM_EXCEPTION (thread_thread_permission, thread_thread_error)
 Exception class indicating insufficient access rights.

 class_DERIVE_FROM_EXCEPTION (thread_thread_notAvailable, thread_thread_error)
 Exception class indicating that an option method is not implemented.

virtual ~LOW_thread_thread ()
 Destructor.

Methods callable by any thread.
virtual bool getIsStarted () const=0
 Indicates if the thread was started.

virtual bool getIsTerminated () const=0
 Indicates if the thread has terminated.

virtual int getReturnValue () const=0
 Get the return value of the thread.

virtual void create ()=0
 Actually create the thread and starts it's runnable's run() method.

virtual void cancel ()=0
 Cancel the execution of the thread.

virtual int join ()=0
 Wait for the termination of the thread.

virtual bool getDetachAvialable () const
 Indicate if thread detaching is available.

virtual void detach ()
 Put a running thread in the detached state.

virtual bool getScheduleModifyAvailable () const
 Indicate if thread scheduling modification is available.

virtual void setScheduling (const LOW_thread_Factory::schedPolicy_t inPolicy, const LOW_thread_Factory::schedPrio_t inPrio)
 Set policy and parameter of scheduling.

virtual LOW_thread_Factory::schedPolicy_t getSchedPolicy () const
 Get the scheduling policy.

virtual LOW_thread_Factory::schedPrio_t getSchedPrio () const
 Get the scheduling parameter.

virtual bool getCancelAttribsAvialable () const
 Indicate if thread cancelling attributes are available.

virtual LOW_thread_Factory::cancelAttrib_t getCancelAttrib () const
 Get cancelling behaviour.

Methods only callable by the own thread.
virtual void thread_exit (const int inRetVal)=0
 Terminate the calling thread.

virtual void testCancel ()=0
 Test on pending cancellation.

virtual void setCancelAttrib (const LOW_thread_Factory::cancelAttrib_t inCancelAttrib)
 Set cancelling behaviour.


Static Private Member Functions

void * threadRunner (void *)
 Helper method for thread launching.


Detailed Description

Abstract base class for threads.

Each instance represents one thread.

Specific platforms dereive their implementation classes from this class. This interface is strongly inspired by the abilities of POSIX threads. As not all OS specific threads have the same abilities, implementation of some methods are optional. Methods are marked accordingly. The default implementation of optional methods just throw a thread_thread_notAvailable exception.

Optional methods are mainly related to the following features:

The instances are created by LOW_thread_Factory, following the factory design pattern.

This class is thread-safe.

See also:
LOW_thread_Factory
Author:
Harald Roelle

Parts of the documentation taken from Linux man pages by Xavier Leroy.

Parts of the documentation taken from IEEE Standard 1003.1-2003.

Definition at line 53 of file LOW_thread_thread.h.


Constructor & Destructor Documentation

LOW_thread_thread::~LOW_thread_thread  )  [virtual]
 

Destructor.

Definition at line 27 of file LOW_thread_thread.cpp.


Member Function Documentation

virtual void LOW_thread_thread::cancel  )  [pure virtual]
 

Cancel the execution of the thread.

Note that the thread is not forced to quit. It depends on the thread implementation when or or if anyway a cancellation request is honored.

Implementation is mandatory.

Exceptions:
thread_thread_error On any error.

Implemented in LOW_thread_thread_POSIX.

LOW_thread_thread::class_DERIVE_FROM_EXCEPTION thread_thread_notAvailable  ,
thread_thread_error 
 

Exception class indicating that an option method is not implemented.

LOW_thread_thread::class_DERIVE_FROM_EXCEPTION thread_thread_permission  ,
thread_thread_error 
 

Exception class indicating insufficient access rights.

LOW_thread_thread::class_DERIVE_FROM_EXCEPTION thread_thread_error  ,
LOW_exception 
 

Exception base class for all exceptions thrown by LOW_thread_thread.

virtual void LOW_thread_thread::create  )  [pure virtual]
 

Actually create the thread and starts it's runnable's run() method.

The new thread terminates either explicitly, by calling thread_exit(), or implicitly, by returning from the run() method. The latter case is equivalent to calling thread_exit() with the result returned by run() as exit code.

Implementation is mandatory.

Exceptions:
thread_thread_error On any error.

Implemented in LOW_thread_thread_POSIX.

void LOW_thread_thread::detach  )  [virtual]
 

Put a running thread in the detached state.

Implementation is optional.

Exceptions:
thread_thread_error On any error.
See also:
getDetachAvialable()

Reimplemented in LOW_thread_thread_POSIX.

Definition at line 43 of file LOW_thread_thread.cpp.

LOW_thread_Factory::cancelAttrib_t LOW_thread_thread::getCancelAttrib  )  const [virtual]
 

Get cancelling behaviour.

Implementation is optional.

Exceptions:
thread_thread_error On any error.

Reimplemented in LOW_thread_thread_POSIX.

Definition at line 79 of file LOW_thread_thread.cpp.

bool LOW_thread_thread::getCancelAttribsAvialable  )  const [virtual]
 

Indicate if thread cancelling attributes are available.

Definition at line 73 of file LOW_thread_thread.cpp.

bool LOW_thread_thread::getDetachAvialable  )  const [virtual]
 

Indicate if thread detaching is available.

Definition at line 37 of file LOW_thread_thread.cpp.

virtual bool LOW_thread_thread::getIsStarted  )  const [pure virtual]
 

Indicates if the thread was started.

Implementation is mandatory.

Returns:
Bool indicating if thread was started.

Implemented in LOW_thread_thread_POSIX.

virtual bool LOW_thread_thread::getIsTerminated  )  const [pure virtual]
 

Indicates if the thread has terminated.

Implementation is mandatory.

Returns:
Bool indicating if thread has terminated.

Implemented in LOW_thread_thread_POSIX.

virtual int LOW_thread_thread::getReturnValue  )  const [pure virtual]
 

Get the return value of the thread.

Implementation is mandatory.

Returns:
Return value of terminated thread.
Exceptions:
thread_thread_error When thread has not terminated yet.

Implemented in LOW_thread_thread_POSIX.

LOW_thread_Factory::schedPolicy_t LOW_thread_thread::getSchedPolicy  )  const [virtual]
 

Get the scheduling policy.

Exceptions:
thread_thread_error On any error.

Reimplemented in LOW_thread_thread_POSIX.

Definition at line 61 of file LOW_thread_thread.cpp.

LOW_thread_Factory::schedPrio_t LOW_thread_thread::getSchedPrio  )  const [virtual]
 

Get the scheduling parameter.

Exceptions:
thread_thread_error On any error.

Reimplemented in LOW_thread_thread_POSIX.

Definition at line 67 of file LOW_thread_thread.cpp.

bool LOW_thread_thread::getScheduleModifyAvailable  )  const [virtual]
 

Indicate if thread scheduling modification is available.

Definition at line 49 of file LOW_thread_thread.cpp.

virtual int LOW_thread_thread::join  )  [pure virtual]
 

Wait for the termination of the thread.

Suspends the execution of the calling thread until the thread terminates, either by calling thread_exit() or by being cancelled.

Implementation is mandatory.

Exceptions:
thread_thread_error On any error.

Implemented in LOW_thread_thread_POSIX.

void LOW_thread_thread::setCancelAttrib const LOW_thread_Factory::cancelAttrib_t  inCancelAttrib  )  [virtual]
 

Set cancelling behaviour.

Changes the cancellation state for the calling thread -- that is, whether cancellation requests are ignored or not and when they are handled.

Implementation is optional.

Parameters:
inCancelAttrib Cancelling handling attribute to set.
Exceptions:
thread_thread_permission Calling thread is not the object's thread.
thread_thread_error On any other error.
See also:
getCancelAttribsAvialable()

Reimplemented in LOW_thread_thread_POSIX.

Definition at line 85 of file LOW_thread_thread.cpp.

void LOW_thread_thread::setScheduling const LOW_thread_Factory::schedPolicy_t  inPolicy,
const LOW_thread_Factory::schedPrio_t  inPrio
[virtual]
 

Set policy and parameter of scheduling.

Parameters:
inPolicy Scheduling policy to apply.
inPolicy Scheduling parameter to apply.
Exceptions:
thread_thread_error On any error.

Reimplemented in LOW_thread_thread_POSIX.

Definition at line 55 of file LOW_thread_thread.cpp.

virtual void LOW_thread_thread::testCancel  )  [pure virtual]
 

Test on pending cancellation.

Method does nothing except testing for pending cancellation and executing it. Its purpose is to introduce explicit checks for cancellation in long sequences of code that do not call cancellation point functions otherwise.

Implementation is mandatory.

Exceptions:
thread_thread_permission Calling thread is not the object's thread.
thread_thread_error On any other error.
See also:
cancel()

Implemented in LOW_thread_thread_POSIX.

virtual void LOW_thread_thread::thread_exit const int  inRetVal  )  [pure virtual]
 

Terminate the calling thread.

Method can only be called by the own thread.

Implementation is mandatory.

Parameters:
inRetVal Return value to quit with.
Exceptions:
thread_thread_permission Calling thread is not the object's thread.
thread_thread_error On any other error.

Implemented in LOW_thread_thread_POSIX.

void* LOW_thread_thread::threadRunner void *   )  [static, private]
 

Helper method for thread launching.

This method gives the possibility to interface with OS-specific calls which require C-style linkage conventions.

Note that when imlementing such a method, special care about thread-safety must be taken.

Reimplemented in LOW_thread_thread_POSIX.


The documentation for this class was generated from the following files:
Generated on Tue Feb 3 11:31:08 2004 for OneWireLibrary++ by doxygen 1.3.2