00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00036 #ifndef OW_THREADIMPL_HPP_INCLUDE_GUARD_
00037 #define OW_THREADIMPL_HPP_INCLUDE_GUARD_
00038 #include "OW_config.h"
00039 #include "OW_Types.hpp"
00040 #include "OW_ThreadTypes.hpp"
00041
00042
00043
00044
00045 namespace OW_NAMESPACE
00046 {
00047
00048
00049
00050
00051 #define OW_THREAD_FLG_JOINABLE 0x000000001
00052 typedef Int32 (*ThreadFunction)(void*);
00059 namespace ThreadImpl
00060 {
00072 OW_COMMON_API int createThread(Thread_t& handle, ThreadFunction func,
00073 void* funcParm, UInt32 threadFlags);
00079 OW_COMMON_API void destroyThread(Thread_t& handle);
00086 inline bool sameThreads(const volatile Thread_t& handle1,
00087 const volatile Thread_t& handle2)
00088 {
00089 #if defined(OW_WIN32)
00090 return handle1 == handle2;
00091 #elif OW_HAVE_PTHREAD_H
00092 return pthread_equal(handle1, handle2);
00093 #endif
00094 }
00102 OW_COMMON_API void exitThread(Thread_t& handle, Int32 rval);
00106 inline Thread_t currentThread()
00107 {
00108 #if defined(OW_WIN32)
00109 return GetCurrentThreadId();
00110 #else
00111 return pthread_self();
00112 #endif
00113 }
00114
00115
00124 OW_COMMON_API UInt64 thread_t_ToUInt64(Thread_t thr);
00125
00134 OW_COMMON_API int setThreadDetached(Thread_t& handle);
00143 OW_COMMON_API int joinThread(Thread_t& handle, Int32& rval);
00148 OW_COMMON_API void yield();
00154 OW_COMMON_API void sleep(UInt32 milliSeconds);
00158 inline OW_DEPRECATED void memoryBarrier()
00159 {
00160
00161 #if defined(__alpha)
00162 __asm__ __volatile__("mb");
00163 #endif
00164
00165
00166 #if defined(__ia64__) || defined(__ia64)
00167 __asm__ __volatile__("mf");
00168 #endif
00169 }
00197 OW_COMMON_API void testCancel();
00198 OW_COMMON_API void saveThreadInTLS(void* pTheThread);
00199 OW_COMMON_API void sendSignalToThread(Thread_t threadID, int signo);
00200 OW_COMMON_API void cancel(Thread_t threadID);
00201 };
00202
00203 }
00204
00205 #endif