diff options
Diffstat (limited to 'ace/OS.h')
-rw-r--r-- | ace/OS.h | 145 |
1 files changed, 44 insertions, 101 deletions
@@ -644,7 +644,6 @@ typedef pthread_mutex_t ACE_thread_mutex_t; #define THR_SCOPE_PROCESS 0x00200000 #define THR_INHERIT_SCHED 0x00400000 #define THR_EXPLICIT_SCHED 0x00800000 -#define THR_USE_AFX 0x01000000 #if !defined (ACE_HAS_STHREADS) #if !defined (ACE_HAS_POSIX_SEM) @@ -663,28 +662,6 @@ struct ACE_sema_t }; #endif /* !ACE_HAS_POSIX_SEM */ -// This is used to implement readers/writer locks for POSIX pthreads. -struct ACE_rwlock_t -{ - ACE_mutex_t lock_; - // Serialize access to internal state. - - ACE_cond_t waiting_readers_; - // Reader threads waiting to acquire the lock. - - int num_waiting_readers_; - // Number of waiting readers. - - ACE_cond_t waiting_writers_; - // Writer threads waiting to acquire the lock. - - int num_waiting_writers_; - // Number of waiting writers. - - int ref_count_; - // Value is -1 if writer has the lock, else this keeps track of the - // number of readers holding the lock. -}; #else // If we are on Solaris we can just reuse the existing implementations // of these synchronization types. @@ -751,59 +728,6 @@ typedef char * ACE_thread_t; typedef int ACE_hthread_t; typedef int ACE_thread_key_t; -struct ACE_cond_t - // = TITLE - // This structure is used to implement condition variables on VxWorks - // - // = DESCRIPTION - // At the current time, this stuff only works for threads - // within the same process, which there's only one of on VxWorks. -{ - long waiters_; - // Number of waiting threads. - - ACE_thread_mutex_t waiters_lock_; - // Serialize access to the waiters count. - - ACE_sema_t sema_; - // Queue up threads waiting for the condition to become signaled. - - ACE_event_t waiters_done_; - // An auto reset event used by the broadcast/signal thread to wait - // for the waiting thread(s) to wake up and get a chance at the - // semaphore. - - size_t was_broadcast_; - // Keeps track of whether we were broadcasting or just signaling. -}; - -struct ACE_rwlock_t - // = TITLE - // This is used to implement readers/writer locks on VxWorks - // - // = DESCRIPTION - // At the current time, this stuff only works for threads - // within the same process, which there's only one of on VxWorks. -{ - ACE_mutex_t lock_; - // Serialize access to internal state. - - ACE_cond_t waiting_readers_; - // Reader threads waiting to acquire the lock. - - int num_waiting_readers_; - // Number of waiting readers. - - ACE_cond_t waiting_writers_; - // Writer threads waiting to acquire the lock. - - int num_waiting_writers_; - // Number of waiting writers. - - int ref_count_; - // Value is -1 if writer has the lock, else this keeps track of the - // number of readers holding the lock. -}; #elif defined (ACE_HAS_WTHREADS) typedef CRITICAL_SECTION ACE_thread_mutex_t; typedef struct @@ -817,28 +741,59 @@ typedef struct } ACE_mutex_t; typedef HANDLE ACE_sema_t; +// These need to be different values, neither of which can be 0... +#define USYNC_THREAD 1 +#define USYNC_PROCESS 2 + +#define THR_CANCEL_DISABLE 0 +#define THR_CANCEL_ENABLE 0 +#define THR_CANCEL_DEFERRED 0 +#define THR_CANCEL_ASYNCHRONOUS 0 +#define THR_DETACHED 0 /* ?? ignore in most places */ +#define THR_BOUND 0 /* ?? ignore in most places */ +#define THR_NEW_LWP 0 /* ?? ignore in most places */ +#define THR_SUSPENDED CREATE_SUSPENDED +#define THR_USE_AFX 0x01000000 +#endif /* ACE_HAS_DCETHREADS || ACE_HAS_PTHREADS */ + +#if defined (ACE_LACKS_COND_T) struct ACE_cond_t // = TITLE - // This structure is used to implement condition variables on NT. + // This structure is used to implement condition variables on + // VxWorks and Win32. // // = DESCRIPTION - // At the current time, this stuff only works for threads - // within the same process. + // At the current time, this stuff only works for threads + // within the same process. { - DWORD waiters_; + long waiters_; // Number of waiting threads. + ACE_thread_mutex_t waiters_lock_; + // Serialize access to the waiters count. + ACE_sema_t sema_; // Queue up threads waiting for the condition to become signaled. + + ACE_event_t waiters_done_; + // An auto reset event used by the broadcast/signal thread to wait + // for the waiting thread(s) to wake up and get a chance at the + // semaphore. + + size_t was_broadcast_; + // Keeps track of whether we were broadcasting or just signaling. }; +#endif /* ACE_LACKS_COND_T */ +#if defined (ACE_LACKS_RWLOCK_T) struct ACE_rwlock_t // = TITLE - // This is used to implement readers/writer locks on NT. + // This is used to implement readers/writer locks on NT, + // VxWorks, and POSIX pthreads. // // = DESCRIPTION - // At the current time, this stuff only works for threads - // within the same process. + // At the current time, this stuff only works for threads + // within the same process. { ACE_mutex_t lock_; // Serialize access to internal state. @@ -859,20 +814,8 @@ struct ACE_rwlock_t // Value is -1 if writer has the lock, else this keeps track of the // number of readers holding the lock. }; +#endif /* ACE_LACKS_RWLOCK_T */ -// These need to be different values, neither of which can be 0... -#define USYNC_THREAD 1 -#define USYNC_PROCESS 2 - -#define THR_CANCEL_DISABLE 0 -#define THR_CANCEL_ENABLE 0 -#define THR_CANCEL_DEFERRED 0 -#define THR_CANCEL_ASYNCHRONOUS 0 -#define THR_DETACHED 0 /* ?? ignore in most places */ -#define THR_BOUND 0 /* ?? ignore in most places */ -#define THR_NEW_LWP 0 /* ?? ignore in most places */ -#define THR_SUSPENDED CREATE_SUSPENDED -#endif /* ACE_HAS_DCETHREADS || ACE_HAS_PTHREADS */ #else /* !ACE_HAS_THREADS, i.e., the OS/platform doesn't support threading. */ // Give these things some reasonable value... #define THR_CANCEL_DISABLE 0 @@ -1806,14 +1749,10 @@ typedef FUNCPTR ACE_THR_FUNC; // where typedef int (*FUNCPTR) (...) typedef void *(*ACE_THR_FUNC)(void *); #endif /* VXWORKS */ -#if defined (ACE_HAS_THR_C_DEST) -// Needed for frigging MVS C++... extern "C" { -typedef void (*ACE_THR_DEST)(void *); +typedef void (*ACE_THR_C_DEST)(void *); } -#else typedef void (*ACE_THR_DEST)(void *); -#endif /* ACE_HAS_THR_C_DEST */ extern "C" { @@ -2422,7 +2361,11 @@ public: static int thr_getspecific (ACE_thread_key_t key, void **data); static int thr_keyfree (ACE_thread_key_t key); static int thr_key_detach (void *inst); +#if defined (ACE_HAS_THR_C_DEST) + static int thr_keycreate (ACE_thread_key_t *key, ACE_THR_C_DEST, void *inst = 0); +#else static int thr_keycreate (ACE_thread_key_t *key, ACE_THR_DEST, void *inst = 0); +#endif /* ACE_HAS_THR_C_DEST */ static int thr_key_used (ACE_thread_key_t key); static size_t thr_min_stack (void); static int thr_setconcurrency (int hint); |