Class: TThreadProgram

Declaration: Task.h

Taxonomy Categories:

Member Functions:


Interface Category:

API.

Inherits From:

MCollectible

Inherited By:

TInstalledTestServer TStandardCaucusReadThread

Purpose:

An abstract base class that defines a protocol to be used for specifying the code and scheduling data to be used by a thread.

Instantiation:

Allocate on the heap or the stack.

Deriving Classes:

Derived classes override the pure virtual member function Run to provide the code to be executed. Other member functions can be overridden as needed.

Concurrency:

Not multithread safe.

Resource Use:

No special requirements.

Other Considerations:

None.

Member Function: TThreadProgram::TThreadProgram

  1. TThreadProgram (const TThreadProgram & source)
  2. TThreadProgram ()

Interface Category:

API.

Purpose:

  1. Copy constructor.
  2. Default constructor.

Calling Context:

  1. Called to copy an object.
  2. Called by the stream-in operators.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TThreadProgram::~TThreadProgram

virtual ~ TThreadProgram ()

Interface Category:

API.

Purpose:

Destructor.

Calling Context:

Called to destroy an object.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TThreadProgram::operator=

TThreadProgram & operator =(const TThreadProgram & sourceThreadProgram)

Interface Category:

API.

Purpose:

Assignment operator.

Calling Context:

Called when an object is assigned to another compatible object.

Parameters:

Return Value:

A non-const reference to the left-hand side object.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TThreadProgram::operator<<=

virtual TStream & operator <<= (TStream & fromWhere)

Interface Category:

API.

Purpose:

Stream-in operator.

Calling Context:

Called to stream in data.

Parameters:

Return Value:

Returns a reference to the stream the object streams itself in from.

Exceptions:

Throws TInvalidVersionError if the object read in from the stream has an invalid version number.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TThreadProgram::operator>>=

virtual TStream & operator >>=(TStream & toWhere) const

Interface Category:

API.

Purpose:

Stream-out operator.

Calling Context:

Called to stream out data.

Parameters:

Return Value:

Returns a reference to the stream the object streams itself out to.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TThreadProgram::CopyThreadSchedule

virtual TThreadSchedule * CopyThreadSchedule () const

Interface Category:

API.

Purpose:

Returns a copy of the TThreadSchedule object to be used by the thread.

Calling Context:

Called by the TThreadHandle constructor before the thread program is run.

Parameters:

Return Value:

A TThreadSchedule object that is a copy of the schedule to use by the thread.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

Override this member function if you don't want the default thread schedule.

Member Function: TThreadProgram::GetStackSize

virtual size_t GetStackSize () const

Interface Category:

API.

Purpose:

Returns the size of the stack to be set up for the thread.

Calling Context:

Called by the TThreadHandle constructor before the thread program is run.

Parameters:

Return Value:

A size_t that represents the stack size in bytes.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

Override this member function if you don't want the default stack size. The default is currently set at 64K.

Member Function: TThreadProgram::GetStack

virtual TMemorySurrogate GetStack ()

Interface Category:

API.

Purpose:

Returns a memory range to be used as the new thread's stack.

Calling Context:

Called by the TThreadHandle constructor before the thread program is run.

Parameters:

Return Value:

A TMemorySurrogate describing the memory range to be used as the thread's stack.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

The default implementation of this member function calls GetStackSize to determine the size of stack to allocate. It then allocates memory from the thread's address space directly from the system's virtual memory system. Override this member function if you want to provide your own stack. Clients should never call this member function.

Member Function: TThreadProgram::DeleteStack

virtual void DeleteStack ()

Interface Category:

API.

Purpose:

Deletes the stack allocated by GetStack.

Calling Context:

Called by the system to delete the stack allocated for the thread running this thread program.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

Override this member function if you overrode GetStack. Clients should never call this member function.

Member Function: TThreadProgram::Prepare

virtual void Prepare ()

Interface Category:

API.

Purpose:

Prepares the thread for execution.

Calling Context:

Called by the new thread when the thread program is run.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

The default implementation of this member function does nothing more than return. You can override this member function if there is some special preparation code that must be run in the newly created thread before calling run. Prepare is run before the completion of the TThreadHandle constructor. If Prepare throws an exception that it does not also catch, then the thread is destroyed and the exception will be rethrown by the TThreadHandle constructor. Clients should never call this member function.

Member Function: TThreadProgram::Run

virtual void Run ()

Interface Category:

API.

Purpose:

The entry point for the code to be run by the thread.

Calling Context:

Called by the new thread when the thread program is run.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

Clients should never call this member function.
Click the icon to mail questions or corrections about this material to Taligent personnel.
Copyright©1995 Taligent,Inc. All rights reserved.