CoreLinux++  0.4.32
Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions | Static Protected Attributes | List of all members
corelinux::Thread Class Reference

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.
 
- Public Member Functions inherited from corelinux::Synchronized
 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...
 
- Protected Member Functions inherited from corelinux::Synchronized
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

- Protected Types inherited from corelinux::Synchronized
typedef GuardGuardPtr
 
typedef const GuardGuardCptr
 
typedef GuardGuardRef
 
typedef const GuardGuardCref
 

Detailed Description

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:

Constructor & Destructor Documentation

corelinux::Thread::Thread ( ThreadCref  )
throw (Assertion
)
protected

Copy constructor won't do, its a singleton.

Parameters
Threadreference to another Thread
Exceptions
AssertionNEVER_GET_HERE

Member Function Documentation

void corelinux::Thread::destroyThreadContext ( ThreadIdentifierCref  anId)
throw ( InvalidThreadException,
Assertion
)
static

Destroys the managed context for the given identifier.

Parameters
ThreadIdentifierunique thread id
Exceptions
InvalidThreadExceptionif the thread id is not one in the managed store.
Assertionif the thread is in a running state.

References corelinux::ThreadContext::getState(), corelinux::THREAD_RUNNING, and corelinux::THREAD_STARTING.

Count corelinux::Thread::getActiveThreadCount ( void  )
static

Retrieve the number of threads that are starting or running.

Returns
Count number of active threads

References corelinux::Singleton< TypeImpl >::instance(), theThreadManager, corelinux::THREAD_RUNNING, and corelinux::THREAD_STARTING.

Count corelinux::Thread::getBlockedThreadCount ( void  )
static

Retrieve the number of threads that are waiting ro tun.

Returns
Count number of active threads

References corelinux::Singleton< TypeImpl >::instance(), theThreadManager, and corelinux::THREAD_WAITING_TO_START.

Count corelinux::Thread::getCompletedThreadCount ( void  )
static

Retrieve the number of threads that are not starting or running or waiting to run.

Returns
Count number of completed threads

References corelinux::Singleton< TypeImpl >::instance(), theThreadManager, and corelinux::THREAD_RUNNING.

Count corelinux::Thread::getCreatedThreadCount ( void  )
static

Retrieve the number of created threads.

Returns
Count number of active threads
Int corelinux::Thread::getKernelError ( void  )
static

getKernelError returns the thread instance errno for the last kernel call the thread made

Returns
Int errno for thread function

Referenced by corelinux::SemaphoreGroup::SemaphoreGroup(), corelinux::AbstractSemaphore::setLock(), and startThread().

ThreadIdentifier corelinux::Thread::getParentThreadIdentifier ( void  )
static

getParentThreadIdentifier retrieves the parent thread of the current thread.

Returns
ThreadIdentifier identifies the parent
ThreadContextCref corelinux::Thread::getThreadContext ( ThreadIdentifierCref  anId)
throw (InvalidThreadException
)
static

Retrieve a ThreadContext given a identifier.

Parameters
ThreadIdentifierunique id
Returns
ThreadContext const reference
Exceptions
InvalidThreadExceptionif it does not exist.

Referenced by getThreadPriority(), setThreadPriority(), and waitForThread().

ThreadIdentifier corelinux::Thread::getThreadIdentifier ( void  )
static
ThreadIdentifierCref corelinux::Thread::getThreadManagerIdentifier ( void  )
static

getThreadManagerIdentifier retrieves the thread that Thread was instantiated from

Returns
ThreadIdentifier identifies the owner
Int corelinux::Thread::getThreadPriority ( ThreadIdentifierCref  anId)
throw ( InvalidThreadException,
Assertion
)
static

Get thread priority for the given indentifier.

Parameters
ThreadIdentifierunique thread id
Exceptions
InvalidThreadExceptionif the thread id is not one in the managed store.
Assertionif the thread is in a running state.

References corelinux::ThreadContext::getIdentifier(), getThreadContext(), and corelinux::Environment::getThreadPriority().

ThreadRef corelinux::Thread::operator= ( ThreadCref  )
throw (Assertion
)
protected

Assignment operator won't do, we should never get here anyway but the compiler will generate the missing method.

Parameters
Threadreference to another Thread
Returns
Thread reference to self
Exceptions
AssertionNEVER_GET_HERE
bool corelinux::Thread::operator== ( ThreadCref  ) const
throw (Assertion
)
protected

Equality operator not valid for class utility.

Parameters
Threadreference to Thread
Returns
bool True if equal
Exceptions
AssertionNEVER_GET_HERE
void corelinux::Thread::setThreadPriority ( ThreadIdentifierCref  anId,
Int  prio 
)
throw ( InvalidThreadException,
Assertion
)
static

Set thread priority for the given indentifier.

Parameters
ThreadIdentifierunique thread id
priopriority value
Exceptions
InvalidThreadExceptionif the thread id is not one in the managed store.
Assertionif the thread is in a running state.

References corelinux::ThreadContext::getIdentifier(), getThreadContext(), and corelinux::Environment::setThreadPriority().

ThreadIdentifier corelinux::Thread::startThread ( ThreadContextRef  aContextRef)
static
Int corelinux::Thread::waitForThread ( ThreadIdentifierCref  anId)
throw (InvalidThreadException
)
static

Blocks the caller until the thread has ended execution, retrieving the return code from the associated thread context.

Parameters
ThreadIdentifierunique thread id
Returns
Int return code from thread context
Exceptions
InvalidThreadExceptionif not a valid thread identifier.

References getThreadContext().


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

This is the CoreLinux++ reference manual
Provided by The CoreLinux Consortium