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 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
    00097         OSCL_IMPORT_REF OsclProcStatus::eOsclProcError Create(TOsclThreadFuncPtr func,
    00098                 int32 stack_size,
    00099                 TOsclThreadFuncArg argument,
    00100                 OsclThread_State state = Start_on_creation,
    00101                 bool oIsJoinable = false
    00102                                                              );
    00103
    00112         OSCL_IMPORT_REF static void Exit(OsclAny* exitcode);
    00113
    00124         OSCL_IMPORT_REF static void EnableKill();
    00125
    00133         OSCL_IMPORT_REF OsclProcStatus::eOsclProcError GetPriority(OsclThreadPriority& refThreadPriority);
    00134
    00144         OSCL_IMPORT_REF OsclProcStatus::eOsclProcError SetPriority(OsclThreadPriority ePriority);
    00145
    00154         OSCL_IMPORT_REF OsclProcStatus::eOsclProcError Suspend();
    00155
    00163         OSCL_IMPORT_REF OsclProcStatus::eOsclProcError Resume();
    00164
    00178         OSCL_IMPORT_REF OsclProcStatus::eOsclProcError Terminate(OsclAny* exitcode);
    00179
    00180
    00186         OSCL_IMPORT_REF static OsclProcStatus::eOsclProcError GetId(TOsclThreadId& refThreadId);
    00187
    00193         OSCL_IMPORT_REF static bool CompareId(TOsclThreadId &t1, TOsclThreadId &t2);
    00194
    00199         OSCL_IMPORT_REF static void SleepMillisec(const int32 msec);
    00200
    00201     private:
    00202
    00210         OsclProcStatus::eOsclProcError MapOsclError(int16 error);
    00211
    00212
    00213         TOsclMutexObject mutex;
    00214         TOsclConditionObject  condition;
    00215         uint8 suspend;
    00216
    00217
    00218
    00219         TOsclThreadObject ObjThread;
    00220         bool bCreated;
    00221         bool iJoined;
    00222 };
    00223
    00224 #endif
    00225