#include <LOW_thread_thread_POSIX.h>
Inheritance diagram for LOW_thread_thread_POSIX:
Public Member Functions | |
virtual | ~LOW_thread_thread_POSIX () |
Destructor. | |
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. | |
Methods callable by any thread. | |
virtual bool | getIsStarted () const |
Indicates if the thread was started. | |
virtual bool | getIsTerminated () const |
Indicates if the thread has terminated. | |
virtual int | getReturnValue () const |
Get the return value of the thread. | |
virtual void | create () |
Actually create the thread and starts it's runnable's run() method. | |
virtual void | cancel () |
Cancel the execution of the thread. | |
virtual int | join () |
Wait for the termination of the thread. | |
virtual void | detach () |
Put a running thread in the detached state. | |
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 LOW_thread_Factory::cancelAttrib_t | getCancelAttrib () const |
Get cancelling behaviour. | |
Methods only callable by the own thread. | |
virtual void | thread_exit (const int inRetVal) |
Terminate the calling thread. | |
virtual void | testCancel () |
Test on pending cancellation. | |
virtual void | setCancelAttrib (const LOW_thread_Factory::cancelAttrib_t inCancelAttrib) |
Set cancelling behaviour. | |
Methods callable by any thread. | |
virtual bool | getDetachAvialable () const |
Indicate if thread detaching is available. | |
virtual bool | getScheduleModifyAvailable () const |
Indicate if thread scheduling modification is available. | |
virtual bool | getCancelAttribsAvialable () const |
Indicate if thread cancelling attributes are available. | |
Static Public Attributes | |
const LOW_thread_Factory::schedPrio_t | schedPrio_default = -1 |
indicator for default scheduling priority | |
Protected Member Functions | |
LOW_thread_thread_POSIX (LOW_thread_runable *inRunable, const LOW_thread_Factory::detachState_t inDetachState=LOW_thread_Factory::detachState_default, const LOW_thread_Factory::schedPolicy_t inSchedPolicy=LOW_thread_Factory::schedPolicy_default, const LOW_thread_Factory::schedPrio_t inSchedPrio=schedPrio_default) | |
Constructor. | |
LOW_thread_thread_POSIX () | |
Constructor. | |
Static Private Member Functions | |
void * | threadRunner (void *inLaunchMe) |
Helper method for thread launching. | |
Private Attributes | |
LOW_thread_runable * | myRunable |
Object providing the run() method. | |
pthread_attr_t | initAttr |
Initial thread attributes. | |
pthread_t | threadID |
ID of the thread. | |
bool | isStarted |
Indicates that thread was launched. | |
bool | isTerminated |
Indicated that thread has terminated. | |
int | returnValue |
Return Value of run() method. | |
LOW_thread_Factory::cancelAttrib_t | cancelAttrib |
Current cancel attribute. | |
LOW_thread_mutex * | createSyncMutex |
Mutex to synchronize with threadRunner on creation. | |
Friends | |
class | LOW_thread_Factory |
To allow construction. |
This class is thread-safe.
Throw more fine grained exceptions.
IEEE Standard 1003.1-2003 (http://www.opengroup.org/onlinepubs/007904975/toc.htm)
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 43 of file LOW_thread_thread_POSIX.h.
|
Destructor.
Definition at line 91 of file LOW_thread_thread_POSIX.cpp. References createSyncMutex, initAttr, LOW_helper_msglog::printPerror(), and threadID. |
|
Constructor. Not publicly constructable. Use LOW_thread_Factory.
Definition at line 33 of file LOW_thread_thread_POSIX.cpp. References createSyncMutex, initAttr, isStarted, isTerminated, LOW_thread_mutex::mutexKind_errorCheck, myRunable, LOW_thread_Factory::new_mutex(), and schedPrio_default. |
|
Constructor. Not publicly constructable. Use LOW_thread_Factory. |
|
Cancel the execution of the thread. Note that the thread is not forced to quit. Cancellation of POSIX threads depends on cancel state and cancel type. The thread can then either ignore the request, honor it immediately, or defer it till it reaches a cancellation point.
Implements LOW_thread_thread. Definition at line 147 of file LOW_thread_thread_POSIX.cpp. References threadID. |
|
Exception class indicating that an option method is not implemented.
|
|
Exception class indicating insufficient access rights.
|
|
Exception base class for all exceptions thrown by LOW_thread_thread.
|
|
Actually create the thread and starts it's runnable's run() method. Execution is synchronized with threadRunner() via createSyncMutex.
Implements LOW_thread_thread. Definition at line 133 of file LOW_thread_thread_POSIX.cpp. References createSyncMutex, getIsStarted(), initAttr, isStarted, threadID, and threadRunner(). |
|
Put a running thread in the detached state. Puts the thread in the detached state. This guarantees that the memory resources consumed by will be freed immediately when it terminates. This also prevents other threads from synchronizing on the termination using join(). A thread can be created initially in the detached state, appropriate constructor argument. In contrast, detach() applies to threads created in the joinable state, and which need to be put in the detached state later. After detach() completes, subsequent attempts to perform join() on it will fail. If another thread is already joining the thread at the time detach() is called, detach() does nothing and leaves the thread in the joinable state.
Reimplemented from LOW_thread_thread. Definition at line 163 of file LOW_thread_thread_POSIX.cpp. References threadID. |
|
Get cancelling behaviour.
Reimplemented from LOW_thread_thread. Definition at line 204 of file LOW_thread_thread_POSIX.cpp. References cancelAttrib, getIsStarted(), and getIsTerminated(). |
|
Indicate if thread cancelling attributes are available.
Definition at line 73 of file LOW_thread_thread.cpp. |
|
Indicate if thread detaching is available.
Definition at line 37 of file LOW_thread_thread.cpp. |
|
Indicates if the thread was started.
Implements LOW_thread_thread. Definition at line 109 of file LOW_thread_thread_POSIX.cpp. References isStarted. Referenced by create(), getCancelAttrib(), and getReturnValue(). |
|
Indicates if the thread has terminated.
Implements LOW_thread_thread. Definition at line 115 of file LOW_thread_thread_POSIX.cpp. References isTerminated. Referenced by getCancelAttrib(), and getReturnValue(). |
|
Get the return value of the thread.
Implements LOW_thread_thread. Definition at line 121 of file LOW_thread_thread_POSIX.cpp. References getIsStarted(), getIsTerminated(), and returnValue. |
|
Get the scheduling policy.
Reimplemented from LOW_thread_thread. Definition at line 180 of file LOW_thread_thread_POSIX.cpp. References threadID. |
|
Get the scheduling parameter.
Reimplemented from LOW_thread_thread. Definition at line 192 of file LOW_thread_thread_POSIX.cpp. References threadID. |
|
Indicate if thread scheduling modification is available.
Definition at line 49 of file LOW_thread_thread.cpp. |
|
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. The thread must be in the joinable state: it must not have been detached using detach() or constructed as detached. When a joinable thread terminates, its memory resources (thread descriptor and stack) are not deallocated until another thread performs join() on it. Therefore, join() must be called once for each joinable thread created to avoid memory leaks. When class is destructed the destructor takes care of this. At most one thread can wait for the termination of a thread. Calling join() on a thread on which another thread is already waiting for termination throws an exception. Implementation is mandatory.
Implements LOW_thread_thread. Definition at line 154 of file LOW_thread_thread_POSIX.cpp. References returnValue, and threadID. |
|
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.
Reimplemented from LOW_thread_thread. Definition at line 233 of file LOW_thread_thread_POSIX.cpp. References cancelAttrib, and threadID. Referenced by threadRunner(). |
|
Set policy and parameter of scheduling.
Reimplemented from LOW_thread_thread. Definition at line 170 of file LOW_thread_thread_POSIX.cpp. References threadID. |
|
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.
Implements LOW_thread_thread. Definition at line 224 of file LOW_thread_thread_POSIX.cpp. References threadID. |
|
Terminate the calling thread. Method can only be called by the own thread.
Implements LOW_thread_thread. Definition at line 215 of file LOW_thread_thread_POSIX.cpp. References threadID. |
|
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 from LOW_thread_thread. Definition at line 271 of file LOW_thread_thread_POSIX.cpp. References createSyncMutex, isTerminated, myRunable, returnValue, LOW_thread_runable::run(), and setCancelAttrib(). Referenced by create(). |
|
To allow construction.
Definition at line 251 of file LOW_thread_thread_POSIX.h. |
|
Current cancel attribute.
Definition at line 292 of file LOW_thread_thread_POSIX.h. Referenced by getCancelAttrib(), and setCancelAttrib(). |
|
Mutex to synchronize with threadRunner on creation.
Definition at line 293 of file LOW_thread_thread_POSIX.h. Referenced by create(), LOW_thread_thread_POSIX(), threadRunner(), and ~LOW_thread_thread_POSIX(). |
|
Initial thread attributes.
Definition at line 287 of file LOW_thread_thread_POSIX.h. Referenced by create(), LOW_thread_thread_POSIX(), and ~LOW_thread_thread_POSIX(). |
|
Indicates that thread was launched.
Definition at line 289 of file LOW_thread_thread_POSIX.h. Referenced by create(), getIsStarted(), and LOW_thread_thread_POSIX(). |
|
Indicated that thread has terminated.
Definition at line 290 of file LOW_thread_thread_POSIX.h. Referenced by getIsTerminated(), LOW_thread_thread_POSIX(), and threadRunner(). |
|
Object providing the run() method.
Definition at line 286 of file LOW_thread_thread_POSIX.h. Referenced by LOW_thread_thread_POSIX(), and threadRunner(). |
|
Return Value of run() method.
Definition at line 291 of file LOW_thread_thread_POSIX.h. Referenced by getReturnValue(), join(), and threadRunner(). |
|
indicator for default scheduling priority
Definition at line 53 of file LOW_thread_thread_POSIX.h. Referenced by LOW_thread_thread_POSIX(). |
|
ID of the thread.
Definition at line 288 of file LOW_thread_thread_POSIX.h. Referenced by cancel(), create(), detach(), getSchedPolicy(), getSchedPrio(), join(), setCancelAttrib(), setScheduling(), testCancel(), thread_exit(), and ~LOW_thread_thread_POSIX(). |