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

oscl_thread.h

Go to the documentation of this file.
00001 // -*- c++ -*-
00002 // = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
00003 
00004 //                  OSCL_T H R E A D (T H R E A D  I M P L E M E N T A T I O N)
00005 
00006 // = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
00007 
00013 // Definition file for OSCL Threads
00014 #ifndef OSCL_THREAD_H_INCLUDED
00015 #define OSCL_THREAD_H_INCLUDED
00016 
00017 #ifndef OSCLCONFIG_PROC_H_INCLUDED
00018 #include "osclconfig_proc.h"
00019 #endif
00020 
00021 #ifndef OSCL_PROCSTATUS_H_INCLUDED
00022 #include "oscl_procstatus.h"
00023 #endif
00024 
00025 #ifndef OSCL_BASE_H_INCLUDED
00026 #include "oscl_base.h"
00027 #endif
00028 
00029 
00030 // Thread state on creation
00031 enum OsclThread_State
00032 {
00033     Start_on_creation
00034     , Suspend_on_creation
00035 };
00036 
00037 // Enumerated Priority Values
00038 enum OsclThreadPriority
00039 {
00040     ThreadPriorityLowest
00041     , ThreadPriorityLow
00042     , ThreadPriorityBelowNormal
00043     , ThreadPriorityNormal
00044     , ThreadPriorityAboveNormal
00045     , ThreadPriorityHighest
00046     , ThreadPriorityTimeCritical
00047 };
00048 
00049 //thread function pointer type.
00050 typedef TOsclThreadFuncRet(OSCL_THREAD_DECL *TOsclThreadFuncPtr)(TOsclThreadFuncArg);
00051 
00058 class OsclThread
00059 {
00060 
00061     public:
00062 
00066         OSCL_IMPORT_REF OsclThread();
00067 
00071         OSCL_IMPORT_REF ~OsclThread();
00072 
00089         OSCL_IMPORT_REF OsclProcStatus::eOsclProcError Create(TOsclThreadFuncPtr func,
00090                 int32 stack_size,
00091                 TOsclThreadFuncArg argument,
00092                 OsclThread_State state = Start_on_creation);
00093 
00102         OSCL_IMPORT_REF static void Exit(OsclAny* exitcode);
00103 
00114         OSCL_IMPORT_REF static void EnableKill();
00115 
00123         OSCL_IMPORT_REF OsclProcStatus::eOsclProcError GetPriority(OsclThreadPriority& refThreadPriority);
00124 
00134         OSCL_IMPORT_REF OsclProcStatus::eOsclProcError SetPriority(OsclThreadPriority ePriority);
00135 
00144         OSCL_IMPORT_REF OsclProcStatus::eOsclProcError Suspend();
00145 
00153         OSCL_IMPORT_REF OsclProcStatus::eOsclProcError Resume();
00154 
00168         OSCL_IMPORT_REF OsclProcStatus::eOsclProcError Terminate(OsclAny* exitcode);
00169 
00170 
00176         OSCL_IMPORT_REF static OsclProcStatus::eOsclProcError GetId(TOsclThreadId& refThreadId);
00177 
00183         OSCL_IMPORT_REF static bool CompareId(TOsclThreadId &t1, TOsclThreadId &t2);
00184 
00189         OSCL_IMPORT_REF static void SleepMillisec(const int32 msec);
00190 
00191     private:
00192 
00200         OsclProcStatus::eOsclProcError MapOsclError(int16 error);
00201 
00202 
00203         TOsclMutexObject mutex;
00204         TOsclConditionObject  condition;
00205         uint8 suspend;
00206 
00207 
00208 
00209         TOsclThreadObject ObjThread;
00210         bool bCreated;
00211 
00212 };
00213 
00214 #endif
00215 

OSCL API
Posting Version: OPENCORE_20090310