CoreLinux++
0.4.32
|
Thread is a framework for the creation, management, and destruction of caller threads. More...
#include <Thread.hpp>
Public Member Functions | |
Thread (void) throw ( Assertion ) | |
Default constructor. | |
virtual | ~Thread (void) |
Virtual destructor. | |
![]() | |
Synchronized (void) | |
Default constructor. | |
Synchronized (SynchronizedCref) | |
Copy constructor. | |
virtual | ~Synchronized (void) |
Virtual Destructor. | |
SynchronizedRef | operator= (SynchronizedCref) |
Assignment operator. | |
bool | operator== (SynchronizedCref) const |
Equality operator. | |
Static Public Member Functions | |
static Int | getKernelError (void) |
getKernelError returns the thread instance errno for the last kernel call the thread made More... | |
static ThreadIdentifier | getThreadIdentifier (void) |
getThreadIdentifier retrieves the kernel process id for the caller thread More... | |
static ThreadIdentifier | getParentThreadIdentifier (void) |
getParentThreadIdentifier retrieves the parent thread of the current thread. More... | |
static ThreadIdentifierCref | getThreadManagerIdentifier (void) |
getThreadManagerIdentifier retrieves the thread that Thread was instantiated from More... | |
static ThreadContextCref | getThreadContext (ThreadIdentifierCref) throw ( InvalidThreadException ) |
Retrieve a ThreadContext given a identifier. More... | |
static Count | getCreatedThreadCount (void) |
Retrieve the number of created threads. More... | |
static Count | getActiveThreadCount (void) |
Retrieve the number of threads that are starting or running. More... | |
static Count | getBlockedThreadCount (void) |
Retrieve the number of threads that are waiting ro tun. More... | |
static Count | getCompletedThreadCount (void) |
Retrieve the number of threads that are not starting or running or waiting to run. More... | |
static void | dump (void) |
Debugging method for the moment. | |
static ThreadIdentifier | startThread (ThreadContextRef) |
Start a thread as described by the context. More... | |
static Int | waitForThread (ThreadIdentifierCref) throw ( InvalidThreadException ) |
Blocks the caller until the thread has ended execution, retrieving the return code from the associated thread context. More... | |
static void | destroyThreadContext (ThreadIdentifierCref) throw ( InvalidThreadException, Assertion ) |
Destroys the managed context for the given identifier. More... | |
static Int | getThreadPriority (ThreadIdentifierCref) throw ( InvalidThreadException, Assertion ) |
Get thread priority for the given indentifier. More... | |
static void | setThreadPriority (ThreadIdentifierCref, Int) throw ( InvalidThreadException, Assertion ) |
Set thread priority for the given indentifier. More... | |
Protected Member Functions | |
Thread (ThreadCref) throw ( Assertion ) | |
Copy constructor won't do, its a singleton. More... | |
ThreadRef | operator= (ThreadCref) throw ( Assertion ) |
Assignment operator won't do, we should never get here anyway but the compiler will generate the missing method. More... | |
bool | operator== (ThreadCref) const throw ( Assertion ) |
Equality operator not valid for class utility. More... | |
![]() | |
Guard | access (void) const throw (SemaphoreException) |
Access returns a instance of Guard which is block scoped to the caller. More... | |
Static Protected Member Functions | |
static void | threadTerminated (Int, VoidPtr, VoidPtr) |
Static Protected Attributes | |
static ThreadManager | theThreadManager |
The singleton instance of Thread for synchronization. | |
Additional Inherited Members | |
![]() | |
typedef Guard * | GuardPtr |
typedef const Guard * | GuardCptr |
typedef Guard & | GuardRef |
typedef const Guard & | GuardCref |
Thread is a framework for the creation, management, and destruction of caller threads.
It accomplishes this by allowing the caller to setup a context for execution and calling their defined entry point. There is still much work to be done such as:
|
protected |
|
static |
Destroys the managed context for the given identifier.
ThreadIdentifier | unique thread id |
InvalidThreadException | if the thread id is not one in the managed store. |
Assertion | if the thread is in a running state. |
References corelinux::ThreadContext::getState(), corelinux::THREAD_RUNNING, and corelinux::THREAD_STARTING.
|
static |
Retrieve the number of threads that are starting or running.
References corelinux::Singleton< TypeImpl >::instance(), theThreadManager, corelinux::THREAD_RUNNING, and corelinux::THREAD_STARTING.
|
static |
Retrieve the number of threads that are waiting ro tun.
References corelinux::Singleton< TypeImpl >::instance(), theThreadManager, and corelinux::THREAD_WAITING_TO_START.
|
static |
Retrieve the number of threads that are not starting or running or waiting to run.
References corelinux::Singleton< TypeImpl >::instance(), theThreadManager, and corelinux::THREAD_RUNNING.
|
static |
Retrieve the number of created threads.
|
static |
getKernelError returns the thread instance errno for the last kernel call the thread made
Referenced by corelinux::SemaphoreGroup::SemaphoreGroup(), corelinux::AbstractSemaphore::setLock(), and startThread().
|
static |
getParentThreadIdentifier retrieves the parent thread of the current thread.
|
static |
Retrieve a ThreadContext given a identifier.
ThreadIdentifier | unique id |
InvalidThreadException | if it does not exist. |
Referenced by getThreadPriority(), setThreadPriority(), and waitForThread().
|
static |
getThreadIdentifier retrieves the kernel process id for the caller thread
Referenced by corelinux::ThreadContext::cloneFrameFunction(), corelinux::GatewaySemaphore::getOwnerRecursionQueueLength(), corelinux::GatewaySemaphore::isAnOwner(), corelinux::MutexSemaphore::lockWithNoWait(), corelinux::GatewaySemaphore::lockWithNoWait(), corelinux::MutexSemaphore::lockWithWait(), corelinux::GatewaySemaphore::lockWithWait(), corelinux::EventSemaphore::post(), corelinux::MutexSemaphore::release(), corelinux::GatewaySemaphore::release(), corelinux::SemaphoreCommon::SemaphoreCommon(), corelinux::EventSemaphore::setLimit(), corelinux::SemaphoreCommon::setLock(), and corelinux::Semaphore::setOwnerId().
|
static |
getThreadManagerIdentifier retrieves the thread that Thread was instantiated from
|
static |
Get thread priority for the given indentifier.
ThreadIdentifier | unique thread id |
InvalidThreadException | if the thread id is not one in the managed store. |
Assertion | if the thread is in a running state. |
References corelinux::ThreadContext::getIdentifier(), getThreadContext(), and corelinux::Environment::getThreadPriority().
|
protected |
|
protected |
|
static |
Set thread priority for the given indentifier.
ThreadIdentifier | unique thread id |
prio | priority value |
InvalidThreadException | if the thread id is not one in the managed store. |
Assertion | if the thread is in a running state. |
References corelinux::ThreadContext::getIdentifier(), getThreadContext(), and corelinux::Environment::setThreadPriority().
|
static |
Start a thread as described by the context.
ThreadContext | reference to thread context object. This object is copied into a managed context. |
References corelinux::ThreadContext::cloneFrameFunction(), corelinux::ThreadContext::createContext(), corelinux::ThreadContext::destroyContext(), getKernelError(), corelinux::ThreadContext::getShareMask(), corelinux::ThreadContext::getStackTop(), corelinux::Singleton< TypeImpl >::instance(), corelinux::ThreadContext::setReturnCode(), corelinux::ThreadContext::setThreadState(), theThreadManager, corelinux::THREAD_RUNNING, corelinux::THREAD_START_EXCEPTION, and corelinux::THREAD_START_FAILED.
|
static |
Blocks the caller until the thread has ended execution, retrieving the return code from the associated thread context.
ThreadIdentifier | unique thread id |
InvalidThreadException | if not a valid thread identifier. |
References getThreadContext().