OsclThread Class Reference

#include <oscl_thread.h>

Public Member Functions

OSCL_IMPORT_REF OsclThread ()
OSCL_IMPORT_REF ~OsclThread ()
OSCL_IMPORT_REF
OsclProcStatus::eOsclProcError 
Create (TOsclThreadFuncPtr func, int32 stack_size, TOsclThreadFuncArg argument, OsclThread_State state=Start_on_creation, bool oIsJoinable=false)
OSCL_IMPORT_REF
OsclProcStatus::eOsclProcError 
GetPriority (OsclThreadPriority &refThreadPriority)
OSCL_IMPORT_REF
OsclProcStatus::eOsclProcError 
SetPriority (OsclThreadPriority ePriority)
OSCL_IMPORT_REF
OsclProcStatus::eOsclProcError 
Suspend ()
OSCL_IMPORT_REF
OsclProcStatus::eOsclProcError 
Resume ()
OSCL_IMPORT_REF
OsclProcStatus::eOsclProcError 
Terminate (OsclAny *exitcode)
OSCL_IMPORT_REF
TOsclThreadTerminate 
CanTerminate ()

Static Public Member Functions

static OSCL_IMPORT_REF void Exit (OsclAny *exitcode)
static OSCL_IMPORT_REF
OsclProcStatus::eOsclProcError 
GetId (TOsclThreadId &refThreadId)
static OSCL_IMPORT_REF bool CompareId (TOsclThreadId &t1, TOsclThreadId &t2)
static OSCL_IMPORT_REF void SleepMillisec (const int32 msec)

Detailed Description

Thread Class. A subset of Thread APIs. It implements platform independendent APIs for thread creation, exiting, suspend, resume, priority and termination. With the use of proper defines it implements the basic thread festures. It provides an opaque layer through which user doesn't need to worry about OS specific data.


Constructor & Destructor Documentation

OSCL_IMPORT_REF OsclThread::OsclThread (  ) 

Class constructor

OSCL_IMPORT_REF OsclThread::~OsclThread (  ) 

Class destructor


Member Function Documentation

OSCL_IMPORT_REF TOsclThreadTerminate OsclThread::CanTerminate (  ) 

Tell if thread terminate will do join, immediate hard kill, or NOP.

Returns:
Terminate behavior.
static OSCL_IMPORT_REF bool OsclThread::CompareId ( TOsclThreadId t1,
TOsclThreadId t2 
) [static]

Static routine to compare whether two thread ID's are equal.

Parameters:
t1,t2,: thread ID passed by the application
Returns:
true if equal.
OSCL_IMPORT_REF OsclProcStatus::eOsclProcError OsclThread::Create ( TOsclThreadFuncPtr  func,
int32  stack_size,
TOsclThreadFuncArg  argument,
OsclThread_State  state = Start_on_creation,
bool  oIsJoinable = false 
)

This routine will create a thread. The thread may be launched immediately or may be created in a suspended state and launched with a Resume call.

Parameters:
func = Name of the thread Function stack_size = Size of the thread stack. If zero, then the platform-specific default stack size will be used. argument = Argument to be passed to thread function state = Enumeration which specifies the state of the thread on creation with values Running and Suspend. Note: the Suspend option may not be available on all platforms. If it is not supported, the Create call will return INVALID_PARAM_ERROR. oIsJoinable = A boolean, which when set to true, creates a Joinable thread. The default value for this is false, which creates a Detached thread. Note 1: When a joinable thread is created, it is imperative to call thread Terminate. Otherwise, it would cause a memory leak. Note 2: This is currently available only for platforms that have support for pthreads.
Returns:
eOsclProcError
static OSCL_IMPORT_REF void OsclThread::Exit ( OsclAny exitcode  )  [static]

Exit is a static function which is used to end the current thread. When called it just ends the execution of the current thread. Note: on some platforms this may be a NOP.

Parameters:
exitcode = Exitcode of the thread. This can be used by other threads to know the exit status of this thread.
Returns:
None
static OSCL_IMPORT_REF OsclProcStatus::eOsclProcError OsclThread::GetId ( TOsclThreadId refThreadId  )  [static]

Static routine to retrieve ID of calling thread.

Parameters:
Thread ID passed by the application
Returns:
Error code
OSCL_IMPORT_REF OsclProcStatus::eOsclProcError OsclThread::GetPriority ( OsclThreadPriority refThreadPriority  ) 

GetThreadPriority gets the priority of the thread. It takes reference of the input argument and assigns priority to it from one of the already defined priorities.

Parameters:
int16& refThreadPriority : Output Priority value
Returns:
Error code
OSCL_IMPORT_REF OsclProcStatus::eOsclProcError OsclThread::Resume (  ) 

ResumeThread resumes the suspended thread and brings it into execution.

Parameters:
None 
Returns:
Error code Note: this function may not be supported on all platforms, and may return NOT_IMPLEMENTED.
OSCL_IMPORT_REF OsclProcStatus::eOsclProcError OsclThread::SetPriority ( OsclThreadPriority  ePriority  ) 

SetThreadPriority sets the priority of the thread. It takes priority as the input argument and assigns it to the thread referred.

Parameters:
ePriorityLevel : Input Priority value
Returns:
Error code Note: this function may not be supported on all platforms, and may return NOT_IMPLEMENTED.
static OSCL_IMPORT_REF void OsclThread::SleepMillisec ( const int32  msec  )  [static]

Suspend current thread execution for specified time.

Parameters:
msec,t2,: sleep time in milliseconds.
OSCL_IMPORT_REF OsclProcStatus::eOsclProcError OsclThread::Suspend (  ) 

This API suspends the thread being referred. The thread can later be brought into execution by calling OSCL_ResumeThread() on it.

Parameters:
None 
Returns:
Error code Note: this function may not be supported on all platforms, and may return NOT_IMPLEMENTED.
OSCL_IMPORT_REF OsclProcStatus::eOsclProcError OsclThread::Terminate ( OsclAny exitcode  ) 

Terminate a thread other than the calling thread.

This API may have multiple behaviors. It may do a hard kill, a "join" operation, or a do-nothing. Caller can use CanTerminate option to tell the behavior in advance.

Parameters:
exitcode = Exitcode of the thread.
Returns:
Error code

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

OSCL API
Posting Version: CORE_9.004.1.1