Main Page Modules Class Hierarchy Data Structures File List Data Fields Globals Related Pages

# OsclThread Class Reference

`#include <oscl_thread.h>`

## Public Methods
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)
## Static Public Methods
OSCL_IMPORT_REF void | Exit (OsclAny *exitcode)
OSCL_IMPORT_REF void | EnableKill ()
OSCL_IMPORT_REF OsclProcStatus::eOsclProcError | GetId (TOsclThreadId &refThreadId)
OSCL_IMPORT_REF bool | CompareId (TOsclThreadId &t1, TOsclThreadId &t2)
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 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

OSCL_IMPORT_REF void OsclThread::EnableKill | ( |  | ) | `[static]`

| EnableKill is a static function which can be called by the thread routine in order to enable thread termination without waiting for cancellation points. EnableKill only applies to pthread implementations. For other implementations this function will do nothing. Returns: None

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. Parameters:
  exitcode | = Exitcode of the thread. This can be used by other threads to know the exit status of this thread.
Returns: None

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.

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. Note: for pthread implementations, the Terminate call will block until the thread has terminated. By default, threads will not terminate until a cancellation point is reached. The EnableKill method may be used to override this default behavior and allow immediate termination. Parameters:
  exitcode | = Exitcode of the thread.
Returns: Error code

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

- oscl_thread.h