corelinux::ThreadContext Class Reference

ThreadContext describes the context in which the thread operates. More...

#include <ThreadContext.hpp>

Inheritance diagram for corelinux::ThreadContext:

corelinux::Synchronized List of all members.

Public Member Functions

 ThreadContext (CallerFunctionPtr) throw ( Assertion )
 Default constructor only requires a caller entry point function.
 ThreadContext (CallerFunctionPtr, Size) throw ( Assertion )
 Constructor which allows the caller to define the stack.
 ThreadContext (ThreadContextCref) throw ( Assertion )
 Copy constructor takes information from the context argument.
virtual ~ThreadContext (void)
 Virtual destructor.
ThreadContextRef operator= (ThreadContextCref) throw ( Assertion )
 Assignment operator changes the context.
bool operator== (ThreadContextCref) const
 Equality operator compares contexts.
bool operator== (ThreadIdentifierCref) const
 Equality matches the thread identifiers.
bool operator== (CallerFunctionPtr) const
 Equality operator matches the callers function.
 operator ThreadIdentifierCref (void) const
 Coerces ThreadContext to ThreadIdentifier.
const ThreadStategetState (void) const
 Get the state of the thread as reflected in its context.
Size getStackSize (void) const
 Get the size of the stack as defined by the context constructor.
Int getShareMask (void) const
 Get the share mask for the thread which determines VM, FILES, FILESYSTEM, SIGNAL shares.
Int getReturnCode (void) const
 Return the code returned by the callers function.
ThreadIdentifierCref getIdentifier (void) const
 Get the identifier for the thread.
virtual ThreadFrameFunctionPtr getFramePointer (void)
 Get the thread frame function pointer.
BytePtr getStack (void)
 Get the stack pointer.
BytePtr * getStackTop (void)
 Get the top of stack pointer.
void setShareMask (Int)
 Change the sharing mask for the thread.
void setFrameFunction (ThreadFrameFunctionPtr)
 Allows the caller to substitute the thread frame entry point.
void setContextFunctions (ThreadContextCreatePtr, ThreadContextDestroyPtr)
 Allows the caller to substitute the routines which create and destroy the managed ThreadContext object.
void setStackFunctions (ThreadStackCreatePtr, ThreadStackDestroyPtr)
 Allows the caller to substitute the routines which create and destroy the managed ThreadContext stack object.
void setReturnCode (Int)
 Set the return code for the thread.
void setThreadState (ThreadState)
 Set the state for the thread.
ThreadContextPtr createContext (void) throw ( ThreadException )
 Create a instance of ourself, we also invoke the create stack method so the instance is ready to be used to run a thread.
void destroyContext (ThreadContextPtr) throw ( Assertion )
 Destroys the context instance.

Static Public Member Functions

static Int cloneFrameFunction (ThreadContextPtr)
 The definitive thread frame entry point.

Protected Member Functions

 ThreadContext (void) throw ( Assertion )
 Default constructor throws NEVER_GET_HERE.
ThreadContextRef operator= (ThreadIdentifier)
 Assignment operator for designating thread identity.
CallerFunctionPtr getCallerFunction (void)
 Return the function pointer of the callers thread routine.

Detailed Description

ThreadContext describes the context in which the thread operates.

Included are stack resource, shared address space flags, factory methods, and state indicators.


Constructor & Destructor Documentation

corelinux::ThreadContext::ThreadContext ( CallerFunctionPtr   )  throw ( Assertion )

Default constructor only requires a caller entry point function.

Defaults in effect are 8k stack which is allocated by the system, and all resources of the caller are shared by the new thread.

Parameters:
CallerFunction pointer to the callers thread routine.
Exceptions:
Assertion if pointer is null

corelinux::ThreadContext::ThreadContext ( CallerFunctionPtr  ,
Size   
) throw ( Assertion )

Constructor which allows the caller to define the stack.

All resources of the caller are shared by the new thread.

Parameters:
CallerFunction pointer to the callers thread routine.
Size Request size for stack in number of bytes.
Exceptions:
Assertion if routine pointer is null or callers stack size is negative.

corelinux::ThreadContext::ThreadContext ( ThreadContextCref   )  throw ( Assertion )

Copy constructor takes information from the context argument.

Parameters:
ThreadContext reference to existing context
Exceptions:
ThreadNotWaitingException if the argument context is not in a THREAD_WAITING_TO_START state.


Member Function Documentation

ThreadContextRef corelinux::ThreadContext::operator= ( ThreadContextCref   )  throw ( Assertion )

Assignment operator changes the context.

Parameters:
ThreadContext reference to existing context
Returns:
ThreadContext reference
Exceptions:
ThreadNotWaitingException if the argument context is not in a THREAD_WAITING_TO_START state.

bool corelinux::ThreadContext::operator== ( ThreadContextCref   )  const

Equality operator compares contexts.

Parameters:
ThreadContext reference to existing context
Returns:
bool true if same

bool corelinux::ThreadContext::operator== ( ThreadIdentifierCref   )  const

Equality matches the thread identifiers.

Parameters:
ThreadIdentifier reference to identifier
Returns:
bool true if same

bool corelinux::ThreadContext::operator== ( CallerFunctionPtr   )  const

Equality operator matches the callers function.

Parameters:
CallerFunctionPtr a function reference
Returns:
bool true if same.

corelinux::ThreadContext::operator ThreadIdentifierCref ( void   )  const

Coerces ThreadContext to ThreadIdentifier.

Returns:
ThreadIdentifier reference

const ThreadState & corelinux::ThreadContext::getState ( void   )  const

Get the state of the thread as reflected in its context.

Returns:
ThreadState

Size corelinux::ThreadContext::getStackSize ( void   )  const

Get the size of the stack as defined by the context constructor.

Returns:
Size in bytes

Int corelinux::ThreadContext::getShareMask ( void   )  const

Get the share mask for the thread which determines VM, FILES, FILESYSTEM, SIGNAL shares.

Returns:
Int

Int corelinux::ThreadContext::getReturnCode ( void   )  const

Return the code returned by the callers function.

This is only valid if the thread ended normally

Returns:
Int return code
See also:
ThreadState

ThreadIdentifierCref corelinux::ThreadContext::getIdentifier ( void   )  const

Get the identifier for the thread.

This is only valid once a thread is started

Returns:
ThreadIdentifier the id

ThreadFrameFunctionPtr corelinux::ThreadContext::getFramePointer ( void   )  [virtual]

Get the thread frame function pointer.

Returns:
ThreadFrameFunctionPtr pointer to instance or default thread frame

void corelinux::ThreadContext::setShareMask ( Int   ) 

Change the sharing mask for the thread.

This is only effective when set prior to starting the thread.

Parameters:
Int mask of values for thread resource sharing and signal disposition

void corelinux::ThreadContext::setFrameFunction ( ThreadFrameFunctionPtr   ) 

Allows the caller to substitute the thread frame entry point.

Parameters:
ThreadFrameFunctionPtr points to the new frame function that is called when starting a thread. If this argument is NULLPTR the default handler is set.

void corelinux::ThreadContext::setContextFunctions ( ThreadContextCreatePtr  ,
ThreadContextDestroyPtr   
)

Allows the caller to substitute the routines which create and destroy the managed ThreadContext object.

The call to create the object comes in at the startThread prior to stack allocation, the call to destroy the object comes from startThread exception and error handling, or when requested by the caller.

Parameters:
ThreadContextCreatePtr the function pointer to set, If this argument is NULLPTR the default handlers are set for create and destroy.
ThreadContextDestroyPtr to the function pointer to set. If this argument is NULLPTR the default handlers are set for create and destroy.

void corelinux::ThreadContext::setStackFunctions ( ThreadStackCreatePtr  ,
ThreadStackDestroyPtr   
)

Allows the caller to substitute the routines which create and destroy the managed ThreadContext stack object.

The call to create the stack object comes in at the startThread prior to threading, the call to destroy the object comes from startThread exception and error handling, or when the destruction of the ThreadContext is imanent.

Parameters:
ThreadStackCreatePtr pointer to set. If this argument is NULLPTR the default handlers are set for create and destroy.
ThreadStackDestroyPtr the function pointer to set. If this argument is NULLPTR the default handlers are set for create and destroy.

void corelinux::ThreadContext::setReturnCode ( Int   ) 

Set the return code for the thread.

Parameters:
Int return code value

void corelinux::ThreadContext::setThreadState ( ThreadState   ) 

Set the state for the thread.

Parameters:
ThreadState the threads new state

Int corelinux::ThreadContext::cloneFrameFunction ( ThreadContextPtr   )  [static]

The definitive thread frame entry point.

This is the address that "clone" gets.

Parameters:
ThreadContext pointer to a thread context
Returns:
Int return code

ThreadContextPtr corelinux::ThreadContext::createContext ( void   )  throw ( ThreadException )

Create a instance of ourself, we also invoke the create stack method so the instance is ready to be used to run a thread.

Returns:
ThreadContext pointer to object.
Exceptions:
ThreadAllocationException either for Stack or Context

void corelinux::ThreadContext::destroyContext ( ThreadContextPtr   )  throw ( Assertion )

Destroys the context instance.

A check is made to insure it is not a suicide.

Parameters:
ThreadContext pointer to context to destroy
Exceptions:
Assertion if self referenced

ThreadContextRef corelinux::ThreadContext::operator= ( ThreadIdentifier   )  [protected]

Assignment operator for designating thread identity.

Parameters:
ThreadIdentifier as retrieved from the OS
Returns:
ThreadContext reference to self

CallerFunctionPtr corelinux::ThreadContext::getCallerFunction ( void   )  [protected]

Return the function pointer of the callers thread routine.

Returns:
CallerFunctionPtr


The documentation for this class was generated from the following files:
This is the CoreLinux++ reference manual
Provided by The CoreLinux Consortium