Posix implementation of IArchMultithread. More...
#include <CArchMultithreadPosix.h>
Inherits IArchMultithread.
Public Member Functions | |
| virtual CArchCond | newCondVar () |
| Create a condition variable. | |
| virtual void | closeCondVar (CArchCond) |
| Destroy a condition variable. | |
| virtual void | signalCondVar (CArchCond) |
| Signal a condition variable. | |
| virtual void | broadcastCondVar (CArchCond) |
| Broadcast a condition variable. | |
| virtual bool | waitCondVar (CArchCond, CArchMutex, double timeout) |
| Wait on a condition variable. | |
| virtual CArchMutex | newMutex () |
| Create a recursive mutex. | |
| virtual void | closeMutex (CArchMutex) |
| Destroy a mutex. | |
| virtual void | lockMutex (CArchMutex) |
| Lock a mutex. | |
| virtual void | unlockMutex (CArchMutex) |
| Unlock a mutex. | |
| virtual CArchThread | newThread (ThreadFunc, void *) |
| Start a new thread. | |
| virtual CArchThread | newCurrentThread () |
| Get a reference to the calling thread. | |
| virtual CArchThread | copyThread (CArchThread) |
| Copy a thread object. | |
| virtual void | closeThread (CArchThread) |
| Release a thread reference. | |
| virtual void | cancelThread (CArchThread) |
| Force a thread to exit. | |
| virtual void | setPriorityOfThread (CArchThread, int n) |
| Change thread priority. | |
| virtual void | testCancelThread () |
| Cancellation point. | |
| virtual bool | wait (CArchThread, double timeout) |
| Wait for a thread to exit. | |
| virtual bool | isSameThread (CArchThread, CArchThread) |
| Compare threads. | |
| virtual bool | isExitedThread (CArchThread) |
| Test if thread exited. | |
| virtual void * | getResultOfThread (CArchThread) |
| Returns the exit code of a thread. | |
| virtual ThreadID | getIDOfThread (CArchThread) |
| Returns an ID for a thread. | |
| virtual void | setSignalHandler (ESignal, SignalFunc, void *) |
| Set the interrupt handler. | |
| virtual void | raiseSignal (ESignal) |
| Invoke the signal handler. | |
manipulators | |
| void | setNetworkDataForCurrentThread (void *) |
accessors | |
|
| |
| void * | getNetworkDataForThread (CArchThread) |
| static CArchMultithreadPosix * | getInstance () |
Posix implementation of IArchMultithread.
Definition at line 39 of file CArchMultithreadPosix.h.
| void CArchMultithreadPosix::broadcastCondVar | ( | CArchCond | ) | [virtual] |
Broadcast a condition variable.
Broadcasting a condition variable releases all waiting threads.
Implements IArchMultithread.
Definition at line 210 of file CArchMultithreadPosix.cpp.
| void CArchMultithreadPosix::cancelThread | ( | CArchThread | thread | ) | [virtual] |
Force a thread to exit.
Causes thread to exit when it next calls a cancellation point. A thread avoids cancellation as long as it nevers calls a cancellation point. Once it begins the cancellation process it must always let cancellation go to completion but may take as long as necessary to clean up.
Implements IArchMultithread.
Definition at line 435 of file CArchMultithreadPosix.cpp.
References lockMutex(), and unlockMutex().
| void CArchMultithreadPosix::closeThread | ( | CArchThread | ) | [virtual] |
Release a thread reference.
Deletes the given thread object. This does not destroy the thread the object referred to, even if there are no remaining references. Use cancelThread() and waitThread() to stop a thread and wait for it to exit.
Implements IArchMultithread.
Definition at line 405 of file CArchMultithreadPosix.cpp.
References lockMutex(), and unlockMutex().
Referenced by wait().
| CArchThread CArchMultithreadPosix::copyThread | ( | CArchThread | thread | ) | [virtual] |
Copy a thread object.
Returns a reference to to thread referred to by thread.
Implements IArchMultithread.
Definition at line 428 of file CArchMultithreadPosix.cpp.
| IArchMultithread::ThreadID CArchMultithreadPosix::getIDOfThread | ( | CArchThread | thread | ) | [virtual] |
Returns an ID for a thread.
Returns some ID number for thread. This is for logging purposes. All thread objects referring to the same thread return the same ID. However, clients should us isSameThread() to compare thread objects instead of comparing IDs.
Implements IArchMultithread.
Definition at line 555 of file CArchMultithreadPosix.cpp.
| void * CArchMultithreadPosix::getResultOfThread | ( | CArchThread | thread | ) | [virtual] |
Returns the exit code of a thread.
Waits indefinitely for thread to exit (if it hasn't yet) then returns the thread's exit code.
(Cancellation point)
Implements IArchMultithread.
Definition at line 546 of file CArchMultithreadPosix.cpp.
References lockMutex(), and unlockMutex().
| bool CArchMultithreadPosix::isExitedThread | ( | CArchThread | thread | ) | [virtual] |
Test if thread exited.
Returns true iff thread has exited.
Implements IArchMultithread.
Definition at line 537 of file CArchMultithreadPosix.cpp.
References lockMutex(), and unlockMutex().
Referenced by wait().
| bool CArchMultithreadPosix::isSameThread | ( | CArchThread | , | |
| CArchThread | ||||
| ) | [virtual] |
Compare threads.
Returns true iff two thread objects refer to the same thread. Note that comparing thread objects directly is meaningless.
Implements IArchMultithread.
Definition at line 531 of file CArchMultithreadPosix.cpp.
| CArchCond CArchMultithreadPosix::newCondVar | ( | ) | [virtual] |
Create a condition variable.
The condition variable is an opaque data type.
Implements IArchMultithread.
Definition at line 183 of file CArchMultithreadPosix.cpp.
| CArchThread CArchMultithreadPosix::newCurrentThread | ( | ) | [virtual] |
Get a reference to the calling thread.
Returns a thread representing the current (i.e. calling) thread.
Implements IArchMultithread.
Definition at line 395 of file CArchMultithreadPosix.cpp.
References lockMutex(), and unlockMutex().
| CArchMutex CArchMultithreadPosix::newMutex | ( | ) | [virtual] |
Create a recursive mutex.
Creates a recursive mutex. A thread may lock a recursive mutex when it already holds a lock on that mutex. The mutex is an opaque data type.
Implements IArchMultithread.
Definition at line 274 of file CArchMultithreadPosix.cpp.
| CArchThread CArchMultithreadPosix::newThread | ( | ThreadFunc | func, | |
| void * | userData | |||
| ) | [virtual] |
Start a new thread.
Creates and starts a new thread, using func as the entry point and passing it userData. The thread is an opaque data type.
Implements IArchMultithread.
Definition at line 339 of file CArchMultithreadPosix.cpp.
References lockMutex(), and unlockMutex().
| void CArchMultithreadPosix::raiseSignal | ( | ESignal | signal | ) | [virtual] |
Invoke the signal handler.
Invokes the signal handler for signal, if any. If no handler cancels the main thread for kINTERRUPT and kTERMINATE and ignores the call otherwise.
Implements IArchMultithread.
Definition at line 571 of file CArchMultithreadPosix.cpp.
References IArchMultithread::kINTERRUPT, IArchMultithread::kTERMINATE, lockMutex(), and unlockMutex().
| void CArchMultithreadPosix::setPriorityOfThread | ( | CArchThread | , | |
| int | n | |||
| ) | [virtual] |
Change thread priority.
Changes the priority of thread by n. If n is positive the thread has a lower priority and if negative a higher priority. Some architectures may not support either or both directions.
Implements IArchMultithread.
Definition at line 455 of file CArchMultithreadPosix.cpp.
| void CArchMultithreadPosix::setSignalHandler | ( | ESignal | , | |
| SignalFunc | func, | |||
| void * | userData | |||
| ) | [virtual] |
Set the interrupt handler.
Sets the function to call on receipt of an external interrupt. By default and when func is NULL, the main thread is cancelled.
Implements IArchMultithread.
Definition at line 561 of file CArchMultithreadPosix.cpp.
References lockMutex(), and unlockMutex().
| void CArchMultithreadPosix::signalCondVar | ( | CArchCond | ) | [virtual] |
Signal a condition variable.
Signalling a condition variable releases one waiting thread.
Implements IArchMultithread.
Definition at line 202 of file CArchMultithreadPosix.cpp.
| void CArchMultithreadPosix::testCancelThread | ( | ) | [virtual] |
Cancellation point.
This method does nothing but is a cancellation point. Clients can make their own functions cancellation points by calling this method at appropriate times.
(Cancellation point)
Implements IArchMultithread.
Definition at line 463 of file CArchMultithreadPosix.cpp.
References lockMutex(), and unlockMutex().
Referenced by waitCondVar().
| bool CArchMultithreadPosix::wait | ( | CArchThread | thread, | |
| double | timeout | |||
| ) | [virtual] |
Wait for a thread to exit.
Waits for up to timeout seconds for thread to exit (normally or by cancellation). Waits forever if timeout < 0. Returns true if the thread exited, false otherwise. Waiting on the current thread returns immediately with false.
(Cancellation point)
Implements IArchMultithread.
Definition at line 475 of file CArchMultithreadPosix.cpp.
References closeThread(), isExitedThread(), lockMutex(), and unlockMutex().
| bool CArchMultithreadPosix::waitCondVar | ( | CArchCond | , | |
| CArchMutex | , | |||
| double | timeout | |||
| ) | [virtual] |
Wait on a condition variable.
Wait on a conditation variable for up to timeout seconds. If timeout is < 0 then there is no timeout. The mutex must be locked when this method is called. The mutex is unlocked during the wait and locked again before returning. Returns true if the condition variable was signalled and false on timeout.
(Cancellation point)
Implements IArchMultithread.
Definition at line 218 of file CArchMultithreadPosix.cpp.
References testCancelThread().
1.7.1