00001 #if !defined(__MCTHREAD_H_)
00002 #define __MCTHREAD_H_
00003
00004 #ident "@(#)$Id: MCThread.h,v 1.6 2004/12/02 07:05:20 mike Exp $"
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #include "mcllib/MCBase.h"
00026 #include "mcllib/MCString.h"
00027 #include "mcllib/MCTypes.h"
00028 #include "mcllib/MCThreadData.h"
00029 #include "mcllib/MCRunnable.h"
00030
00031 namespace mcllib
00032 {
00041 class MCThread : public MCBase
00042 {
00043 public:
00045 enum EType {
00046 THRTYPEUSER,
00047 THRTYPESYS
00048 };
00050 enum EScope {
00051 THRSCOPELOCAL,
00052 THRSCOPEGLOBAL,
00053 THRSCOPEBOUND
00054 };
00056 enum EState {
00057 THRSTATEJOIN,
00058 THRSTATENOJOIN
00059 };
00061 enum EPriority {
00062 THRPRILOW,
00063 THRPRINORMAL,
00064 THRPRIHIGH,
00065 THRPRIURGENT
00066 };
00070 MCThread();
00075 MCThread(const MCString& name);
00095 void start(MCRunnable* pRunnable,
00096 EType type = THRTYPEUSER,
00097 EScope scope = THRSCOPELOCAL,
00098 EState state = THRSTATEJOIN,
00099 EPriority pri = THRPRINORMAL,
00100 mcstacksize_t sz = 0);
00106 void setPriority(EPriority pri);
00112 void setInterrupt();
00118 void join();
00126 const MCString& getName() const;
00135 mcthreadid_t getId() const;
00143 static MCRefPtr<MCThreadData> getData(mcthreaddatakey_t index);
00152 static void setData(mcthreaddatakey_t index, MCThreadData* pData);
00164 static void setDataAll(mcthreaddatakey_t index,
00165 MCThreadData* pData);
00178 static mcthreaddatakey_t getDataIndex(const MCString& key);
00184 static void sleep(mcinterval_t interval);
00190 static void yield();
00195 static void clearInterrupt();
00200 static MCThread getCurrentThread();
00201
00202 private:
00203
00204 MCThread(void* impl);
00205
00207 static void blockInterrupt();
00209 static void unblockInterrupt();
00210 };
00211 };
00212
00213
00214 #endif