#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) |
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.
OSCL_IMPORT_REF OsclThread::OsclThread | ( | ) |
Class constructor
OSCL_IMPORT_REF OsclThread::~OsclThread | ( | ) |
Class destructor
OSCL_IMPORT_REF TOsclThreadTerminate OsclThread::CanTerminate | ( | ) |
Tell if thread terminate will do join, immediate hard kill, or NOP.
static OSCL_IMPORT_REF bool OsclThread::CompareId | ( | TOsclThreadId & | t1, | |
TOsclThreadId & | t2 | |||
) | [static] |
Static routine to compare whether two thread ID's are equal.
t1,t2,: | thread ID passed by the application |
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.
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. |
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.
exitcode | = Exitcode of the thread. This can be used by other threads to know the exit status of this thread. |
static OSCL_IMPORT_REF OsclProcStatus::eOsclProcError OsclThread::GetId | ( | TOsclThreadId & | refThreadId | ) | [static] |
Static routine to retrieve ID of calling thread.
Thread | ID passed by the application |
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.
int16& | refThreadPriority : Output Priority value |
OSCL_IMPORT_REF OsclProcStatus::eOsclProcError OsclThread::Resume | ( | ) |
ResumeThread resumes the suspended thread and brings it into execution.
None |
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.
ePriorityLevel | : Input Priority value |
static OSCL_IMPORT_REF void OsclThread::SleepMillisec | ( | const int32 | msec | ) | [static] |
Suspend current thread execution for specified time.
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.
None |
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.
exitcode | = Exitcode of the thread. |