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

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 termiante options
00050 enum TOsclThreadTerminate
00051 {
00052     EOsclThreadTerminate_Join,
00053     EOsclThreadTerminate_Kill,
00054     EOsclThreadTerminate_NOP
00055 };
00056 
00057 
00058 //thread function pointer type.
00059 typedef TOsclThreadFuncRet(OSCL_THREAD_DECL *TOsclThreadFuncPtr)(TOsclThreadFuncArg);
00060 
00067 class OsclThread
00068 {
00069 
00070     public:
00071 
00075         OSCL_IMPORT_REF OsclThread();
00076 
00080         OSCL_IMPORT_REF ~OsclThread();
00081 
00106         OSCL_IMPORT_REF OsclProcStatus::eOsclProcError Create(TOsclThreadFuncPtr func,
00107                 int32 stack_size,
00108                 TOsclThreadFuncArg argument,
00109                 OsclThread_State state = Start_on_creation,
00110                 bool oIsJoinable = false);
00111 
00121         OSCL_IMPORT_REF static void Exit(OsclAny* exitcode);
00122 
00130         OSCL_IMPORT_REF OsclProcStatus::eOsclProcError GetPriority(OsclThreadPriority& refThreadPriority);
00131 
00141         OSCL_IMPORT_REF OsclProcStatus::eOsclProcError SetPriority(OsclThreadPriority ePriority);
00142 
00151         OSCL_IMPORT_REF OsclProcStatus::eOsclProcError Suspend();
00152 
00160         OSCL_IMPORT_REF OsclProcStatus::eOsclProcError Resume();
00161 
00173         OSCL_IMPORT_REF OsclProcStatus::eOsclProcError Terminate(OsclAny* exitcode);
00174 
00179         OSCL_IMPORT_REF TOsclThreadTerminate CanTerminate();
00180 
00181 
00187         OSCL_IMPORT_REF static OsclProcStatus::eOsclProcError GetId(TOsclThreadId& refThreadId);
00188 
00194         OSCL_IMPORT_REF static bool CompareId(TOsclThreadId &t1, TOsclThreadId &t2);
00195 
00200         OSCL_IMPORT_REF static void SleepMillisec(const int32 msec);
00201 
00202     private:
00203 
00211         OsclProcStatus::eOsclProcError MapOsclError(int16 error);
00212 
00213 
00214         TOsclMutexObject mutex;
00215         TOsclConditionObject  condition;
00216         uint8 suspend;
00217         bool bJoinable;
00218 
00219 
00220 
00221         TOsclThreadObject ObjThread;
00222         bool bCreated;
00223 };
00224 
00225 #endif
00226 

OSCL API
Posting Version: CORE_8.508.1.1