diff options
Diffstat (limited to 'ace/OS_NS_Thread.h')
-rw-r--r-- | ace/OS_NS_Thread.h | 159 |
1 files changed, 14 insertions, 145 deletions
diff --git a/ace/OS_NS_Thread.h b/ace/OS_NS_Thread.h index 021f664c2ab..745f5c730d1 100644 --- a/ace/OS_NS_Thread.h +++ b/ace/OS_NS_Thread.h @@ -29,7 +29,6 @@ # include "ace/Basic_Types.h" # include "ace/Default_Constants.h" # include "ace/os_include/os_pthread.h" -# include "ace/os_include/os_sched.h" # include "ace/Base_Thread_Adapter.h" # include "ace/os_include/sys/os_sem.h" # include "ace/os_include/os_semaphore.h" @@ -55,8 +54,6 @@ # include /**/ <sys/tspriocntl.h> # endif /* ACE_HAS_PRIOCNTL */ -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - # if defined (ACE_PSOS) // Use pSOS semaphores, wrapped . . . typedef struct @@ -118,8 +115,6 @@ typedef DWORD ACE_OS_thread_key_t; # endif /* ! ACE_HAS_TSS_EMULATION */ # endif /* ACE_WIN32 */ -ACE_END_VERSIONED_NAMESPACE_DECL - # if !defined (ACE_HAS_POSIX_SEM) && defined (ACE_USES_FIFO_SEM) extern "C" { @@ -155,9 +150,6 @@ extern "C" { # if defined (ACE_HAS_PTHREADS) // moved to pthread.h # elif defined (ACE_HAS_STHREADS) - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - // Solaris threads, without PTHREADS. // Typedefs to help compatibility with Windows NT and Pthreads. typedef thread_t ACE_thread_t; @@ -189,8 +181,6 @@ struct ACE_Export ACE_mutexattr_t typedef ACE_thread_t ACE_hthread_t; typedef ACE_mutex_t ACE_thread_mutex_t; -ACE_END_VERSIONED_NAMESPACE_DECL - # define THR_CANCEL_DISABLE 0 # define THR_CANCEL_ENABLE 0 # define THR_CANCEL_DEFERRED 0 @@ -202,8 +192,6 @@ ACE_END_VERSIONED_NAMESPACE_DECL # elif defined (ACE_PSOS) -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - // Some versions of pSOS provide native mutex support. For others, // implement ACE_thread_mutex_t and ACE_mutex_t using pSOS semaphores. // Either way, the types are all u_longs. @@ -245,8 +233,6 @@ typedef u_int ACE_OS_thread_key_t; typedef ACE_OS_thread_key_t ACE_thread_key_t; # endif /* ! ACE_HAS_TSS_EMULATION */ -ACE_END_VERSIONED_NAMESPACE_DECL - # define THR_CANCEL_DISABLE 0 /* thread can never be cancelled */ # define THR_CANCEL_ENABLE 0 /* thread can be cancelled */ # define THR_CANCEL_DEFERRED 0 /* cancellation deferred to cancellation point */ @@ -282,12 +268,10 @@ ACE_END_VERSIONED_NAMESPACE_DECL /* #define T_NOFPU 0x00000000 Not using FPU */ /* #define T_FPU 0x00000002 Using FPU bit */ -# elif defined (ACE_VXWORKS) +# elif defined (VXWORKS) # include /**/ <sysLib.h> // for sysClkRateGet() -# if !defined (__RTP__) -# include /**/ <taskLib.h> -# include /**/ <taskHookLib.h> -# endif +# include /**/ <taskLib.h> +# include /**/ <taskHookLib.h> // make sure these are included for VXWORKS. // @todo move these to a common place, perhaps the top of the file. @@ -306,9 +290,7 @@ ACE_END_VERSIONED_NAMESPACE_DECL // task options: the other options are either obsolete, internal, or for // Fortran or Ada support # define VX_UNBREAKABLE 0x0002 /* breakpoints ignored */ -# if !defined (VX_FP_TASK) -# define VX_FP_TASK 0x0008 /* floating point coprocessor */ -# endif +# define VX_FP_TASK 0x0008 /* floating point coprocessor */ # define VX_PRIVATE_ENV 0x0080 /* private environment support */ # define VX_NO_STACK_FILL 0x0100 /* do not stack fill for checkstack () */ @@ -335,8 +317,6 @@ ACE_END_VERSIONED_NAMESPACE_DECL # define USYNC_PROCESS 1 /* It's all global on VxWorks (without MMU option). */ -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - typedef SEM_ID ACE_mutex_t; // Implement ACE_thread_mutex_t with ACE_mutex_t because there's just // one process . . . @@ -366,16 +346,12 @@ typedef u_int ACE_OS_thread_key_t; typedef ACE_OS_thread_key_t ACE_thread_key_t; # endif /* ! ACE_HAS_TSS_EMULATION */ -ACE_END_VERSIONED_NAMESPACE_DECL - // Marker for ACE_Thread_Manager to indicate that it allocated // an ACE_thread_t. It is placed at the beginning of the ID. # define ACE_THR_ID_ALLOCATED '\022' # elif defined (ACE_HAS_WTHREADS) -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - typedef CRITICAL_SECTION ACE_thread_mutex_t; typedef struct @@ -420,8 +396,6 @@ public: # endif /* ACE_USES_WINCE_SEMA_SIMULATION */ # endif /* defined (ACE_WIN32) */ -ACE_END_VERSIONED_NAMESPACE_DECL - // These need to be different values, neither of which can be 0... # define USYNC_THREAD 1 # define USYNC_PROCESS 2 @@ -449,9 +423,6 @@ ACE_END_VERSIONED_NAMESPACE_DECL // takes care of it) unless we're on Windows. Win32 mutexes, semaphores, // and condition variables are not yet supported in PACE. # if defined (ACE_LACKS_COND_T) - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - /** * @class ACE_cond_t * @@ -510,15 +481,10 @@ struct ACE_Export ACE_mutexattr_t { int type; }; - -ACE_END_VERSIONED_NAMESPACE_DECL - # endif /* ACE_LACKS_COND_T */ # if defined (ACE_LACKS_RWLOCK_T) && !defined (ACE_HAS_PTHREADS_UNIX98_EXT) -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - /** * @class ACE_rwlock_t * @@ -558,18 +524,11 @@ public: /// Condition for the upgrading reader ACE_cond_t waiting_important_writer_; }; - -ACE_END_VERSIONED_NAMESPACE_DECL - # elif defined (ACE_HAS_PTHREADS_UNIX98_EXT) -ACE_BEGIN_VERSIONED_NAMESPACE_DECL typedef pthread_rwlock_t ACE_rwlock_t; -ACE_END_VERSIONED_NAMESPACE_DECL # elif defined (ACE_HAS_STHREADS) # include /**/ <synch.h> -ACE_BEGIN_VERSIONED_NAMESPACE_DECL typedef rwlock_t ACE_rwlock_t; -ACE_END_VERSIONED_NAMESPACE_DECL # endif /* ACE_LACKS_RWLOCK_T */ // Define some default thread priorities on all threaded platforms, if @@ -619,9 +578,6 @@ ACE_END_VERSIONED_NAMESPACE_DECL // and recursive_mutex_cond_relock() methods to maintain the expected // state when the wait finishes. # if defined (ACE_HAS_RECURSIVE_MUTEXES) - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - typedef ACE_thread_mutex_t ACE_recursive_thread_mutex_t; # if defined (ACE_WIN32) // Windows has recursive mutexes, but doesn't have condition variables, @@ -637,13 +593,7 @@ struct ACE_recursive_mutex_state // No need for special handling; just need a type for method signatures. typedef int ACE_recursive_mutex_state; # endif /* ACE_WIN32 */ - -ACE_END_VERSIONED_NAMESPACE_DECL - # else - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - /** * @class ACE_recursive_thread_mutex_t * @@ -678,9 +628,6 @@ struct ACE_recursive_mutex_state int nesting_level_; ACE_thread_t owner_id_; }; - -ACE_END_VERSIONED_NAMESPACE_DECL - # endif /* ACE_HAS_RECURSIVE_MUTEXES */ # else /* !ACE_HAS_THREADS, i.e., the OS/platform doesn't support threading. */ @@ -747,8 +694,6 @@ ACE_END_VERSIONED_NAMESPACE_DECL # define THR_SCOPE_SYSTEM 0 # endif /* ! THR_SCOPE_SYSTEM */ -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - // These are dummies needed for class OS.h typedef int ACE_cond_t; struct ACE_Export ACE_condattr_t @@ -778,8 +723,6 @@ typedef unsigned int ACE_OS_thread_key_t; typedef ACE_OS_thread_key_t ACE_thread_key_t; # endif /* ! ACE_HAS_TSS_EMULATION */ -ACE_END_VERSIONED_NAMESPACE_DECL - // Ensure that ACE_THR_PRI_FIFO_DEF and ACE_THR_PRI_OTHER_DEF are // defined on non-threaded platforms, to support application source // code compatibility. ACE_THR_PRI_FIFO_DEF should be used by @@ -794,8 +737,6 @@ ACE_END_VERSIONED_NAMESPACE_DECL # endif /* ACE_HAS_THREADS ***********************************************/ -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - /** * @class ACE_Thread_ID * @@ -852,14 +793,14 @@ private: typedef int ACE_Sched_Priority; # if !defined (ACE_DEFAULT_SYNCH_TYPE) -# if defined (ACE_VXWORKS) +# if defined (VXWORKS) // Types include these options: SEM_Q_PRIORITY, SEM_Q_FIFO, // SEM_DELETE_SAFE, and SEM_INVERSION_SAFE. SEM_Q_FIFO is // used as the default because that is VxWorks' default. # define ACE_DEFAULT_SYNCH_TYPE SEM_Q_FIFO # else # define ACE_DEFAULT_SYNCH_TYPE USYNC_THREAD -# endif /* ACE_VXWORKS */ +# endif /* VXWORKS */ #endif /* ! ACE_DEFAULT_SYNCH_TYPE */ // forward declaration @@ -955,7 +896,7 @@ public: * address on success. Returns 0 if local TSS had already been * setup for this thread. There is no corresponding tss_close () * because it is not needed. - * @note tss_open () is called by ACE for threads that it spawns. + * NOTE: tss_open () is called by ACE for threads that it spawns. * If your application spawns threads without using ACE, and it uses * ACE's TSS emulation, each of those threads should call tss_open * (). See the ace_thread_adapter () implementation for an example. @@ -1162,43 +1103,24 @@ private: # define ACE_KEY_INDEX(OBJ,KEY) u_int OBJ = KEY # endif /* ACE_HAS_NONSCALAR_THREAD_KEY_T */ -ACE_END_VERSIONED_NAMESPACE_DECL - -#if (defined (ACE_HAS_VERSIONED_NAMESPACE) \ - && ACE_HAS_VERSIONED_NAMESPACE == 1) \ - && !(defined (_MSC_VER) && _MSC_VER <= 1200) -// MSVC++ 6's preprocessor can't handle macro expansions required by -// the versioned namespace support. *sigh* - -# define ACE_MUTEX_LOCK_CLEANUP_ADAPTER_NAME ACE_PREPROC_CONCATENATE(ACE_VERSIONED_NAMESPACE_NAME, _ace_mutex_lock_cleanup_adapter) - -#else - -# define ACE_MUTEX_LOCK_CLEANUP_ADAPTER_NAME ace_mutex_lock_cleanup_adapter - -#endif /* ACE_HAS_VERSIONED_NAMESPACE == 1 */ - - # if defined (ACE_HAS_THR_C_FUNC) // This is necessary to work around nasty problems with MVS C++. -extern "C" ACE_Export void ACE_MUTEX_LOCK_CLEANUP_ADAPTER_NAME (void *args); -# define ACE_PTHREAD_CLEANUP_PUSH(A) pthread_cleanup_push (ACE_MUTEX_LOCK_CLEANUP_ADAPTER_NAME, (void *) A); +extern "C" ACE_Export void ace_mutex_lock_cleanup_adapter (void *args); +# define ACE_PTHREAD_CLEANUP_PUSH(A) pthread_cleanup_push (ace_mutex_lock_cleanup_adapter, (void *) A); # define ACE_PTHREAD_CLEANUP_POP(A) pthread_cleanup_pop(A) # elif defined (ACE_HAS_PTHREADS) && !defined (ACE_LACKS_PTHREAD_CLEANUP) // Though we are defining a extern "C" function to match the prototype of // pthread_cleanup_push, it is undone by the Solaris header file // /usr/include/pthread.h. So this macro generates a warning under Solaris // with SunCC. This is a bug in the Solaris header file. -extern "C" ACE_Export void ACE_MUTEX_LOCK_CLEANUP_ADAPTER_NAME (void *args); -# define ACE_PTHREAD_CLEANUP_PUSH(A) pthread_cleanup_push (ACE_MUTEX_LOCK_CLEANUP_ADAPTER_NAME, (void *) A); +extern "C" ACE_Export void ace_mutex_lock_cleanup_adapter (void *args); +# define ACE_PTHREAD_CLEANUP_PUSH(A) pthread_cleanup_push (ace_mutex_lock_cleanup_adapter, (void *) A); # define ACE_PTHREAD_CLEANUP_POP(A) pthread_cleanup_pop(A) # else # define ACE_PTHREAD_CLEANUP_PUSH(A) # define ACE_PTHREAD_CLEANUP_POP(A) # endif /* ACE_HAS_THR_C_FUNC */ -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - # if !defined (ACE_WIN32) // forward decl's class ACE_event_t; @@ -1282,7 +1204,6 @@ namespace ACE_OS { const char *name = 0, void *arg = 0); -# if defined (ACE_HAS_WCHAR) # if defined (ACE_LACKS_COND_T) && ! defined (ACE_PSOS_DIAB_MIPS) extern ACE_Export # else @@ -1302,7 +1223,6 @@ namespace ACE_OS { ACE_condattr_t &attributes, const wchar_t *name, void *arg = 0); -# endif /* ACE_HAS_WCHAR */ #if defined (ACE_LACKS_COND_T) && ! defined (ACE_PSOS_DIAB_MIPS) extern ACE_Export @@ -1361,7 +1281,6 @@ namespace ACE_OS { void *arg = 0, LPSECURITY_ATTRIBUTES sa = 0); -# if defined (ACE_HAS_WCHAR) ACE_NAMESPACE_INLINE_FUNCTION int event_init (ACE_event_t *event, int manual_reset, @@ -1370,7 +1289,6 @@ namespace ACE_OS { const wchar_t *name, void *arg = 0, LPSECURITY_ATTRIBUTES sa = 0); -# endif /* ACE_HAS_WCHAR */ extern ACE_Export int event_pulse (ACE_event_t *event); @@ -1411,7 +1329,6 @@ namespace ACE_OS { LPSECURITY_ATTRIBUTES sa = 0, int lock_type = 0); -#if defined (ACE_HAS_WCHAR) extern ACE_Export int mutex_init (ACE_mutex_t *m, int lock_scope, @@ -1419,7 +1336,6 @@ namespace ACE_OS { ACE_mutexattr_t *arg = 0, LPSECURITY_ATTRIBUTES sa = 0, int lock_type = 0); -#endif /* ACE_HAS_WCHAR */ /// Win32 note: Abandoned mutexes are not treated differently. 0 is /// returned since the calling thread does get the ownership. @@ -1576,7 +1492,6 @@ namespace ACE_OS { int max = 0x7fffffff, LPSECURITY_ATTRIBUTES sa = 0); -# if defined (ACE_HAS_WCHAR) ACE_NAMESPACE_INLINE_FUNCTION int sema_init (ACE_sema_t *s, u_int count, @@ -1585,7 +1500,6 @@ namespace ACE_OS { void *arg = 0, int max = 0x7fffffff, LPSECURITY_ATTRIBUTES sa = 0); -# endif /* ACE_HAS_WCHAR */ ACE_NAMESPACE_INLINE_FUNCTION int sema_post (ACE_sema_t *s); @@ -1747,40 +1661,7 @@ namespace ACE_OS { ACE_THR_FUNC_RETURN *status); /** - * Get the thread affinity - * - * @param thr_id For NPTL-threads, when ACE_HAS_PTHREAD_SETAFFINITY_NP - * defined, this is the thread-id. For linux-threads, when - * ACE_HAS_SCHED_SETAFFINITY defined, it expects a process-id. Since for - * linux-threads a thread is seen as a process, it does the job. - * @param cpu_set_size The size of the cpu_mask - * @param cpu_mask Is a bitmask of CPUs to bind to, e.g value 1 binds the - * thread to the "CPU 0", etc - */ - extern ACE_Export - int thr_get_affinity (ACE_hthread_t id, - size_t cpu_set_size, - cpu_set_t * cpu_mask); - - - /** - * Set the thread affinity - * - * @param thr_id For NPTL-threads, when ACE_HAS_PTHREAD_SETAFFINITY_NP - * defined, this is the thread-id. For linux-threads, when - * ACE_HAS_SCHED_SETAFFINITY defined, it expects a process-id. Since for - * linux-threads a thread is seen as a process, it does the job. - * @param cpu_set_size The size of the cpu_mask - * @param cpu_mask Is a bitmask of CPUs to bind to, e.g value 1 binds the - * thread to the "CPU 0", etc - */ - extern ACE_Export - int thr_set_affinity (ACE_hthread_t thr_id, - size_t cpu_set_size, - const cpu_set_t * cpu_mask); - - /** - * @note the "inst" arg is deprecated. It will be ignored. + * @note the "inst" arge is deprecated. It will be ignored. */ extern ACE_Export int thr_key_detach (ACE_thread_key_t key, void * inst); @@ -1897,13 +1778,11 @@ namespace ACE_OS { const char *name = 0, ACE_mutexattr_t *arg = 0); -#if defined (ACE_HAS_WCHAR) ACE_NAMESPACE_INLINE_FUNCTION int thread_mutex_init (ACE_thread_mutex_t *m, int lock_type, const wchar_t *name, ACE_mutexattr_t *arg = 0); -#endif /* ACE_HAS_WCHAR */ ACE_NAMESPACE_INLINE_FUNCTION int thread_mutex_lock (ACE_thread_mutex_t *m); @@ -1936,15 +1815,13 @@ namespace ACE_OS { void unique_name (const void *object, char *name, size_t length); -#if defined (ACE_USES_WCHAR) + extern ACE_Export void unique_name (const void *object, wchar_t *name, size_t length); -#endif /* ACE_USES_WCHAR */ -} /* namespace ACE_OS */ -ACE_END_VERSIONED_NAMESPACE_DECL +} /* namespace ACE_OS */ #if !defined (ACE_WIN32) @@ -1994,8 +1871,6 @@ extern "C" } ACE_eventdata_t; } -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - /** * @class ACE_event_t * @@ -2032,14 +1907,10 @@ protected: #endif }; -ACE_END_VERSIONED_NAMESPACE_DECL - #endif /* ACE_WIN32 */ #if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0) -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - /** * @class ACE_OS_Thread_Mutex_Guard * @@ -2132,8 +2003,6 @@ protected: const ACE_OS_Recursive_Thread_Mutex_Guard &); }; -ACE_END_VERSIONED_NAMESPACE_DECL - // used in time and unistd # define ACE_OS_GUARD \ ACE_OS_Thread_Mutex_Guard ace_os_guard__ (*(ACE_thread_mutex_t *) \ |