version 1.1.2.5, 2006/07/28 20:49:59
|
version 1.1.2.10, 2006/08/02 07:26:35
|
|
|
| |
//============================================================================== | //============================================================================== |
// | // |
// Thread-related type definitions |
// ThreadType |
// | // |
//============================================================================== | //============================================================================== |
| |
#if defined(PEGASUS_HAVE_PTHREADS) | #if defined(PEGASUS_HAVE_PTHREADS) |
|
|
struct ThreadType | struct ThreadType |
{ | { |
public: | public: |
|
|
return *this; | return *this; |
} | } |
| |
pthread_t handle() const |
pthread_t tt_handle() const |
{ | { |
return _thread; | return _thread; |
} | } |
|
|
| |
private: | private: |
pthread_t _thread; | pthread_t _thread; |
|
// An id of zero indicates a null object. 1 indicates the main thread. |
// And id of zero indicates a null object. 1 indicates the main thread. |
|
Uint32 _id; | Uint32 _id; |
friend class Threads; | friend class Threads; |
}; | }; |
|
#endif /* PEGASUS_HAVE_PTHREADS */ |
typedef void* ThreadReturnType; |
|
#endif |
|
| |
#if defined(PEGASUS_HAVE_WINDOWS_THREADS) | #if defined(PEGASUS_HAVE_WINDOWS_THREADS) |
struct ThreadType | struct ThreadType |
{ | { |
|
ThreadType() : handle(NULL) { } |
HANDLE handle; | HANDLE handle; |
}; | }; |
|
#endif /* PEGASUS_HAVE_WINDOWS_THREADS */ |
|
|
|
//============================================================================== |
|
// |
|
// ThreadReturnType |
|
// |
|
//============================================================================== |
|
|
|
#if defined(PEGASUS_HAVE_PTHREADS) |
|
typedef void* ThreadReturnType; |
|
#endif |
|
|
|
#if defined(PEGASUS_HAVE_WINDOWS_THREADS) |
typedef unsigned ThreadReturnType; | typedef unsigned ThreadReturnType; |
#endif | #endif |
| |
|
|
| |
inline bool Threads::equal(ThreadType x, ThreadType y) | inline bool Threads::equal(ThreadType x, ThreadType y) |
{ | { |
return pthread_equal(x.thread(), y.thread()); |
return pthread_equal(x.tt_handle(), y.tt_handle()); |
} | } |
| |
inline void Threads::exit(ThreadReturnType rc) | inline void Threads::exit(ThreadReturnType rc) |
|
|
| |
inline void Threads::cancel(ThreadType th, ThreadReturnType rc) | inline void Threads::cancel(ThreadType th, ThreadReturnType rc) |
{ | { |
pthread_cancel(th.thread()); |
pthread_cancel(th.tt_handle()); |
} | } |
| |
inline void Threads::yield() | inline void Threads::yield() |
|
|
defined(PEGASUS_PLATFORM_HPUX_ACC) || \ | defined(PEGASUS_PLATFORM_HPUX_ACC) || \ |
defined(PEGASUS_PLATFORM_OS400_ISERIES_IBM) || \ | defined(PEGASUS_PLATFORM_OS400_ISERIES_IBM) || \ |
defined(PEGASUS_PLATFORM_TRU64_ALPHA_DECCXX) || \ | defined(PEGASUS_PLATFORM_TRU64_ALPHA_DECCXX) || \ |
defined(PEGASUS_OS_VMS) |
defined(PEGASUS_OS_VMS) || \ |
|
defined(PEGASUS_OS_ZOS) |
sched_yield(); | sched_yield(); |
#else | #else |
pthread_yield(); | pthread_yield(); |