diff options
author | Johnny Willemsen <jwillemsen@remedy.nl> | 2007-11-27 08:30:10 +0000 |
---|---|---|
committer | Johnny Willemsen <jwillemsen@remedy.nl> | 2007-11-27 08:30:10 +0000 |
commit | 68064c65a9d491c0fb61b6a84e2d479b9316a4b1 (patch) | |
tree | df230971e9d84373a2d3291d40456ac8c86dfde5 | |
parent | 97d9d92121005e27e4ab5887cd9281ae2362e0bb (diff) | |
download | ATCD-68064c65a9d491c0fb61b6a84e2d479b9316a4b1.tar.gz |
-rw-r--r-- | ACE/ChangeLog | 14 | ||||
-rw-r--r-- | ACE/ace/OS_NS_Thread.cpp | 35 | ||||
-rw-r--r-- | ACE/ace/OS_NS_Thread.h | 12 | ||||
-rw-r--r-- | ACE/ace/OS_NS_Thread.inl | 22 | ||||
-rw-r--r-- | ACE/ace/SOCK_Dgram_Mcast.cpp | 54 | ||||
-rw-r--r-- | ACE/ace/SOCK_Dgram_Mcast.h | 40 | ||||
-rw-r--r-- | ACE/ace/Task.cpp | 10 | ||||
-rw-r--r-- | ACE/ace/Task.h | 3 | ||||
-rw-r--r-- | ACE/ace/Thread.cpp | 16 | ||||
-rw-r--r-- | ACE/ace/Thread.h | 15 | ||||
-rw-r--r-- | ACE/ace/Thread.inl | 6 | ||||
-rw-r--r-- | ACE/ace/Thread_Manager.cpp | 32 | ||||
-rw-r--r-- | ACE/ace/Thread_Manager.h | 73 |
13 files changed, 158 insertions, 174 deletions
diff --git a/ACE/ChangeLog b/ACE/ChangeLog index d773c418a78..d6f782d5700 100644 --- a/ACE/ChangeLog +++ b/ACE/ChangeLog @@ -1,3 +1,17 @@ +Tue Nov 27 08:27:54 UTC 2007 Johnny Willemsen <jwillemsen@remedy.nl> + + * ace/OS_NS_Thread.{h,cpp,inl}: + * ace/Task.{h,cpp}: + * ace/Thread.{h,cpp,inl}: + * ace/Thread_Manager.{h,cpp}: + Added a const char* argument to all methods that create a thread + so that we can pass in an optional thread name which is used at + this moment only on VxWorks. Added ACE_OS::thr_name() to retrieve + the name of the current thread. + + * ace/SOCK_Dgram_Mcast.{h,cpp}: + Removed deprecated subscribe/unsubscribe methods + Tue Nov 27 06:33:54 UTC 2007 Johnny Willemsen <jwillemsen@remedy.nl> * examples/Reactor/Multicast/Log_Wrapper.cpp: diff --git a/ACE/ace/OS_NS_Thread.cpp b/ACE/ace/OS_NS_Thread.cpp index dd6499128f5..aff75e3c511 100644 --- a/ACE/ace/OS_NS_Thread.cpp +++ b/ACE/ace/OS_NS_Thread.cpp @@ -1152,8 +1152,7 @@ ACE_OS::cleanup_tss (const u_int main_thread) // @@ The following functions could be inlined if i could figure where // to put it among the #ifdefs! int -ACE_OS::condattr_init (ACE_condattr_t &attributes, - int type) +ACE_OS::condattr_init (ACE_condattr_t &attributes, int type) { attributes.type = type; return 0; @@ -3821,7 +3820,8 @@ ACE_OS::thr_create (ACE_THR_FUNC func, long priority, void *stack, size_t stacksize, - ACE_Base_Thread_Adapter *thread_adapter) + ACE_Base_Thread_Adapter *thread_adapter, + const char** thr_name) { ACE_OS_TRACE ("ACE_OS::thr_create"); @@ -3837,7 +3837,6 @@ ACE_OS::thr_create (ACE_THR_FUNC func, # define ACE_THREAD_ARGUMENT thread_args #endif /* ! defined (ACE_NO_THREAD_ADAPTER) */ - ACE_Base_Thread_Adapter *thread_args = 0; if (thread_adapter == 0) #if defined (ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS) @@ -3881,7 +3880,6 @@ ACE_OS::thr_create (ACE_THR_FUNC func, thr_handle = &tmp_handle; # if defined (ACE_HAS_PTHREADS) - int result; # if defined (ACE_VXWORKS) && (ACE_VXWORKS >= 0x600) && (ACE_VXWORKS <= 0x620) /* Tests show that VxWorks 6.x pthread lib does not only @@ -4167,6 +4165,24 @@ ACE_OS::thr_create (ACE_THR_FUNC func, ACE_UNUSED_ARG (priority); # endif /* ACE_LACKS_SETSCHED */ + // *** Set pthread name +# if defined (ACE_HAS_PTHREAD_ATTR_SETNAME) + if (thr_name && *thr_name) + { + if (ACE_ADAPT_RETVAL(::pthread_attr_setname (&attr, *thr_name), result) != 0) + { +# if defined (ACE_HAS_PTHREADS_DRAFT4) + ::pthread_attr_delete (&attr); +# else /* ACE_HAS_PTHREADS_DRAFT4 */ + ::pthread_attr_destroy (&attr); +# endif /* ACE_HAS_PTHREADS_DRAFT4 */ + return -1; + } + } +#else + ACE_UNUSED_ARG (thr_name); +# endif + // *** Set Scope # if !defined (ACE_LACKS_THREAD_PROCESS_SCOPING) if (ACE_BIT_ENABLED (flags, THR_SCOPE_SYSTEM) @@ -4396,6 +4412,7 @@ ACE_OS::thr_create (ACE_THR_FUNC func, auto_thread_args.release (); return result; # elif defined (ACE_HAS_WTHREADS) + ACE_UNUSED_ARG (thr_name); ACE_UNUSED_ARG (stack); # if defined (ACE_HAS_MFC) && (ACE_HAS_MFC != 0) if (ACE_BIT_ENABLED (flags, THR_USE_AFX)) @@ -4501,7 +4518,7 @@ ACE_OS::thr_create (ACE_THR_FUNC func, // The call below to ::taskSpawn () causes VxWorks to assign a // unique task name of the form: "t" + an integer, because the // first argument is 0. - tid = ::taskSpawn (0, + tid = ::taskSpawn (thr_name && *thr_name ? const_cast <char*> (*thr_name) : 0, priority, (int) flags, (int) stacksize, @@ -4521,7 +4538,7 @@ ACE_OS::thr_create (ACE_THR_FUNC func, // The TID is defined to be the address of the TCB. int status = ::taskInit (tcb, - thr_id_provided ? *thr_id : 0, + thr_name && *thr_name ? const_cast <char*>(*thr_name) : 0, priority, (int) flags, (char *) stack + sizeof (WIND_TCB), @@ -4550,6 +4567,9 @@ ACE_OS::thr_create (ACE_THR_FUNC func, if (thr_handle) *thr_handle = tid; + if (thr_name && !(*thr_name)) + *thr_name = ::taskName (tid); + auto_thread_args.release (); return 0; } @@ -4564,6 +4584,7 @@ ACE_OS::thr_create (ACE_THR_FUNC func, ACE_UNUSED_ARG (priority); ACE_UNUSED_ARG (stack); ACE_UNUSED_ARG (stacksize); + ACE_UNUSED_ARG (thr_name); ACE_NOTSUP_RETURN (-1); #endif /* ACE_HAS_THREADS */ } diff --git a/ACE/ace/OS_NS_Thread.h b/ACE/ace/OS_NS_Thread.h index 0f3237109b1..e41adec4d84 100644 --- a/ACE/ace/OS_NS_Thread.h +++ b/ACE/ace/OS_NS_Thread.h @@ -1535,6 +1535,10 @@ namespace ACE_OS { * * Note that @a thread_adapter is always deleted by @c thr_create, * therefore it must be allocated with global operator new. + * + * At the moment for @a thr_name a valid string is passed then this + * will be used on VxWorks to set the task name. If we just pass a pointer + * the name of the task is returned */ extern ACE_Export int thr_create (ACE_THR_FUNC func, @@ -1545,7 +1549,8 @@ namespace ACE_OS { long priority = ACE_DEFAULT_THREAD_PRIORITY, void *stack = 0, size_t stacksize = ACE_DEFAULT_THREAD_STACKSIZE, - ACE_Base_Thread_Adapter *thread_adapter = 0); + ACE_Base_Thread_Adapter *thread_adapter = 0, + const char** thr_name = 0); ACE_NAMESPACE_INLINE_FUNCTION int thr_equal (ACE_thread_t t1, @@ -1669,7 +1674,7 @@ namespace ACE_OS { # endif /* ACE_HAS_THR_C_DEST */ # if defined (ACE_HAS_THREAD_SPECIFIC_STORAGE) - /// @internal applications should call thr_keyfree instead + /// @internal Applications should call thr_keyfree instead extern ACE_Export int thr_keyfree_native (ACE_OS_thread_key_t key); # endif /* ACE_HAS_THREAD_SPECIFIC_STORAGE */ @@ -1691,6 +1696,9 @@ namespace ACE_OS { void thr_self (ACE_hthread_t &); ACE_NAMESPACE_INLINE_FUNCTION + const char* thr_name (void); + + ACE_NAMESPACE_INLINE_FUNCTION int thr_setcancelstate (int new_state, int *old_state); diff --git a/ACE/ace/OS_NS_Thread.inl b/ACE/ace/OS_NS_Thread.inl index ddb67ecb7e3..94cbe373e84 100644 --- a/ACE/ace/OS_NS_Thread.inl +++ b/ACE/ace/OS_NS_Thread.inl @@ -3077,6 +3077,20 @@ ACE_OS::thr_self (void) #endif /* ACE_HAS_THREADS */ } +ACE_INLINE const char* +ACE_OS::thr_name (void) +{ +#if defined (ACE_HAS_THREADS) +#if defined (ACE_HAS_VXTHREADS) + return ::taskName (ACE_OS::thr_self ()); +#else + ACE_NOTSUP_RETURN (0); +#endif +#else + ACE_NOTSUP_RETURN (0); +#endif +} + ACE_INLINE void ACE_OS::thr_self (ACE_hthread_t &self) { @@ -3118,7 +3132,7 @@ ACE_OS::thr_setcancelstate (int new_state, int *old_state) # else /* this is draft 7 or std */ int result; ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_setcancelstate (new_state, - old_state), + old_state), result), int, -1); # endif /* ACE_HAS_PTHREADS_DRAFT4 */ @@ -3161,7 +3175,7 @@ ACE_OS::thr_setcanceltype (int new_type, int *old_type) # else /* this is draft 7 or std */ int result; ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_setcanceltype (new_type, - old_type), + old_type), result), int, -1); # endif /* ACE_HAS_PTHREADS_DRAFT4 */ @@ -3242,8 +3256,8 @@ ACE_OS::thr_setprio (ACE_hthread_t ht_id, int priority, int policy) param.sched_priority = priority; ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_setschedparam (ht_id, - policy, - ¶m), + policy, + ¶m), result), int, -1); # endif /* ACE_HAS_PTHREADS_DRAFT4 */ diff --git a/ACE/ace/SOCK_Dgram_Mcast.cpp b/ACE/ace/SOCK_Dgram_Mcast.cpp index 8cd47bfe444..baa49f521e5 100644 --- a/ACE/ace/SOCK_Dgram_Mcast.cpp +++ b/ACE/ace/SOCK_Dgram_Mcast.cpp @@ -462,22 +462,6 @@ ACE_SOCK_Dgram_Mcast::subscribe_ifs (const ACE_INET_Addr &mcast_addr, } -// Subscribe and add address/iface to subscription list if successful. -int -ACE_SOCK_Dgram_Mcast::subscribe (const ACE_INET_Addr &mcast_addr, - int reuse_addr, - const ACE_TCHAR *net_if, - int protocol_family, - int protocol) -{ - ACE_TRACE ("ACE_SOCK_Dgram_Mcast::subscribe"); - - ACE_UNUSED_ARG (protocol_family); - ACE_UNUSED_ARG (protocol); - - return this->join (mcast_addr,reuse_addr, net_if); -} - int ACE_SOCK_Dgram_Mcast::join (const ACE_INET_Addr &mcast_addr, int reuse_addr, @@ -810,24 +794,6 @@ ACE_SOCK_Dgram_Mcast::unsubscribe_ifs (const ACE_INET_Addr &mcast_addr, } -// Unsubscribe, and remove address from subscription list. -// Note: If there are duplicate entries, only finds the first in the list (this -// is a defined restriction - most environments don't allow duplicates to be -// created.) -int -ACE_SOCK_Dgram_Mcast::unsubscribe (const ACE_INET_Addr &mcast_addr, - const ACE_TCHAR *net_if, - int protocol_family, - int protocol) -{ - ACE_TRACE ("ACE_SOCK_Dgram_Mcast::unsubscribe"); - - ACE_UNUSED_ARG (protocol_family); - ACE_UNUSED_ARG (protocol); - - return this->leave (mcast_addr, net_if); -} - int ACE_SOCK_Dgram_Mcast::leave (const ACE_INET_Addr &mcast_addr, const ACE_TCHAR *net_if) @@ -940,26 +906,6 @@ ACE_SOCK_Dgram_Mcast::unsubscribe_i (const ACE_INET_Addr &mcast_addr, } int -ACE_SOCK_Dgram_Mcast::unsubscribe (void) -{ - ACE_TRACE ("ACE_SOCK_Dgram_Mcast::unsubscribe"); - - // Can't implement this reliably without keeping an expensive list, - // and can't close the socket since the caller may want to continue - // using the socket to send() or join() new groups. Even if we - // wanted to be clever and reopen the socket, we'd need to know what - // options had been set, and reset them--and we have no way of doing - // that either. :-( - // Should this return -1? - ACE_ERROR_RETURN ((LM_INFO, - ACE_TEXT ("ACE_SOCK_Dgram_Mcast::unsubscribe (void) ") - ACE_TEXT ("has been deprecated. You must either ") - ACE_TEXT ("close to socket to unsubscribe to all ") - ACE_TEXT ("or unsubscribe to each individually.\n")), - 0); -} - -int ACE_SOCK_Dgram_Mcast::clear_subs_list (void) { ACE_TRACE ("ACE_SOCK_Dgram_Mcast::clear_subs_list"); diff --git a/ACE/ace/SOCK_Dgram_Mcast.h b/ACE/ace/SOCK_Dgram_Mcast.h index 1f53e9f0646..a7e668b4be0 100644 --- a/ACE/ace/SOCK_Dgram_Mcast.h +++ b/ACE/ace/SOCK_Dgram_Mcast.h @@ -250,18 +250,9 @@ public: * Note that the optional @a reuse_addr parameter does not apply to * subscriptions; it is only used if <open> is implicitly invoked (see above). * - * @deprecated This method has been deprecated, please use join() instead. - * In addition, the following parameters have also been deprecated: - * @a protocol_family and @a protocol have no effect. + * Uses the mcast_addr to determine protocol_family, and protocol which + * we always pass as 0 anyway. */ - int subscribe (const ACE_INET_Addr &mcast_addr, - int reuse_addr = 1, // (see above) - const ACE_TCHAR *net_if = 0, - int protocol_family = PF_INET, - int protocol = 0); - - /// join() replaces subscribe() and uses the mcast_addr to determine - /// protocol_family, and protocol which we always pass as 0 anyway. int join (const ACE_INET_Addr &mcast_addr, int reuse_addr = 1, // (see above) const ACE_TCHAR *net_if = 0); @@ -281,35 +272,12 @@ public: * implemented in this environment (_even if_ the <subscribe> specifies a * non- NULL <net_if>). * - * @deprecated This method has been deprecated. Please use leave() instead. - * In addition, @a protocol_family and @a protocol have no effect. + * leave() replaces unsubscribe() and uses mcast_addr to determine + * protocol_family, and protocol which we always pass as 0 anyway. */ - int unsubscribe (const ACE_INET_Addr &mcast_addr, - const ACE_TCHAR *net_if = 0, - int protocol_family = PF_INET, - int protocol = 0); - - /// leave() replaces unsubscribe() and uses mcast_addr to determine - /// protocol_family, and protocol which we always pass as 0 anyway. int leave (const ACE_INET_Addr &mcast_addr, const ACE_TCHAR *net_if = 0); - /// Unsubscribe all current subscriptions. - /** - * Unsubscribe all active group/interface subscriptions (if any). - * - * Returns -1 if any unsubscribe failed, 0 if there are no errors or no - * current subscriptions. - * - * @deprecated This method has been deprecated. Since a list of groups is - * not maintained (except when ACE_SOCK_DGRAM_MCAST_DUMPABLE is defined), - * it isn't possible to unsubscribe to all the groups without closing - * the socket. Therefore, if applications wish to unsubscribe to all - * groups without closing the socket, they much keep track of the - * subscriptions and call the above unsubscribe () for each. - */ - int unsubscribe (void); - // = Data transfer routines. /// Send @a n bytes in @a buf, using the multicast address and network interface diff --git a/ACE/ace/Task.cpp b/ACE/ace/Task.cpp index 0fd50115756..a58ba93e2dc 100644 --- a/ACE/ace/Task.cpp +++ b/ACE/ace/Task.cpp @@ -126,7 +126,8 @@ ACE_Task_Base::activate (long flags, ACE_hthread_t thread_handles[], void *stack[], size_t stack_size[], - ACE_thread_t thread_ids[]) + ACE_thread_t thread_ids[], + const char* thr_name[]) { ACE_TRACE ("ACE_Task_Base::activate"); @@ -171,7 +172,8 @@ ACE_Task_Base::activate (long flags, task, thread_handles, stack, - stack_size); + stack_size, + thr_name); else // thread names were specified grp_spawned = @@ -185,7 +187,8 @@ ACE_Task_Base::activate (long flags, stack, stack_size, thread_handles, - task); + task, + thr_name); if (grp_spawned == -1) { // If spawn_n fails, restore original thread count. @@ -217,6 +220,7 @@ ACE_Task_Base::activate (long flags, ACE_UNUSED_ARG (stack); ACE_UNUSED_ARG (stack_size); ACE_UNUSED_ARG (thread_ids); + ACE_UNUSED_ARG (thr_name); ACE_NOTSUP_RETURN (-1); } #endif /* ACE_MT_SAFE */ diff --git a/ACE/ace/Task.h b/ACE/ace/Task.h index b289f4e756f..757cf651323 100644 --- a/ACE/ace/Task.h +++ b/ACE/ace/Task.h @@ -185,7 +185,8 @@ public: ACE_hthread_t thread_handles[] = 0, void *stack[] = 0, size_t stack_size[] = 0, - ACE_thread_t thread_ids[] = 0); + ACE_thread_t thread_ids[] = 0, + const char* thr_name[] = 0); /** * Block until there are no more threads running in this task. diff --git a/ACE/ace/Thread.cpp b/ACE/ace/Thread.cpp index ffdf195c40c..fab00ea5e6b 100644 --- a/ACE/ace/Thread.cpp +++ b/ACE/ace/Thread.cpp @@ -22,7 +22,8 @@ ACE_Thread::spawn_n (size_t n, long priority, void *stack[], size_t stack_size[], - ACE_Thread_Adapter *thread_adapter) + ACE_Thread_Adapter *thread_adapter, + const char* thr_name[]) { ACE_TRACE ("ACE_Thread::spawn_n"); ACE_thread_t t_id; @@ -38,7 +39,8 @@ ACE_Thread::spawn_n (size_t n, priority, stack == 0 ? 0 : stack[i], stack_size == 0 ? ACE_DEFAULT_THREAD_STACKSIZE : stack_size[i], - thread_adapter) != 0) + thread_adapter, + thr_name == 0 ? 0 : &thr_name[i]) != 0) break; return i; @@ -54,17 +56,18 @@ ACE_Thread::spawn_n (ACE_thread_t thread_ids[], void *stack[], size_t stack_size[], ACE_hthread_t thread_handles[], - ACE_Thread_Adapter *thread_adapter) + ACE_Thread_Adapter *thread_adapter, + const char* thr_name[]) { ACE_TRACE ("ACE_Thread::spawn_n"); - size_t i; + size_t i = 0; for (i = 0; i < n; i++) { ACE_thread_t t_id; ACE_hthread_t t_handle; - int result = + int const result = ACE_OS::thr_create (func, arg, flags, @@ -73,7 +76,8 @@ ACE_Thread::spawn_n (ACE_thread_t thread_ids[], priority, stack == 0 ? 0 : stack[i], stack_size == 0 ? ACE_DEFAULT_THREAD_STACKSIZE : stack_size[i], - thread_adapter); + thread_adapter, + thr_name == 0 ? 0 : &thr_name[i]); if (result == 0) { diff --git a/ACE/ace/Thread.h b/ACE/ace/Thread.h index f343a05484a..9800997df16 100644 --- a/ACE/ace/Thread.h +++ b/ACE/ace/Thread.h @@ -89,7 +89,8 @@ public: long priority = ACE_DEFAULT_THREAD_PRIORITY, void *stack = 0, size_t stack_size = ACE_DEFAULT_THREAD_STACKSIZE, - ACE_Thread_Adapter *thread_adapter = 0); + ACE_Thread_Adapter *thread_adapter = 0, + const char** thr_name = 0); /** * Spawn N new threads, which execute @a func with argument @a arg (if @@ -112,12 +113,13 @@ public: long priority = ACE_DEFAULT_THREAD_PRIORITY, void *stack[] = 0, size_t stack_size[] = 0, - ACE_Thread_Adapter *thread_adapter = 0); + ACE_Thread_Adapter *thread_adapter = 0, + const char* thr_name[] = 0); /** - * Spawn @a n new threads, which execute @a func with argument <arg> - * (if <thread_adapter> is non-0 then @a func and <args> are ignored - * and are obtained from <thread_adapter>). The thread_ids of + * Spawn @a n new threads, which execute @a func with argument @a arg + * (if @a thread_adapter is non-0 then @a func and @a args are ignored + * and are obtained from @a thread_adapter). The thread_ids of * successfully spawned threads will be placed into the <thread_ids> * buffer (which must be the same size as @a n). If @a stack != 0 it * is assumed to be an array of @a n pointers to the base of the @@ -141,7 +143,8 @@ public: void *stack[] = 0, size_t stack_size[] = 0, ACE_hthread_t thread_handles[] = 0, - ACE_Thread_Adapter *thread_adapter = 0); + ACE_Thread_Adapter *thread_adapter = 0, + const char* thr_name[] = 0); /** * Wait for one or more threads to exit and reap their exit status. diff --git a/ACE/ace/Thread.inl b/ACE/ace/Thread.inl index ba635c6b2f0..6c292ab27cd 100644 --- a/ACE/ace/Thread.inl +++ b/ACE/ace/Thread.inl @@ -82,7 +82,8 @@ ACE_Thread::spawn (ACE_THR_FUNC func, long priority, void *thr_stack, size_t thr_stack_size, - ACE_Thread_Adapter *thread_adapter) + ACE_Thread_Adapter *thread_adapter, + const char** thr_name) { ACE_TRACE ("ACE_Thread::spawn"); @@ -94,7 +95,8 @@ ACE_Thread::spawn (ACE_THR_FUNC func, priority, thr_stack, thr_stack_size, - thread_adapter); + thread_adapter, + thr_name); } ACE_INLINE int diff --git a/ACE/ace/Thread_Manager.cpp b/ACE/ace/Thread_Manager.cpp index 9248a6ad42e..d164039ba1b 100644 --- a/ACE/ace/Thread_Manager.cpp +++ b/ACE/ace/Thread_Manager.cpp @@ -550,7 +550,8 @@ ACE_Thread_Manager::spawn_i (ACE_THR_FUNC func, int grp_id, void *stack, size_t stack_size, - ACE_Task_Base *task) + ACE_Task_Base *task, + const char** thr_name) { // First, threads created by Thread Manager should not be daemon threads. // Using assertion is probably a bit too strong. However, it helps @@ -608,7 +609,8 @@ ACE_Thread_Manager::spawn_i (ACE_THR_FUNC func, priority, stack, stack_size, - thread_args); + thread_args, + thr_name); if (result != 0) { @@ -663,7 +665,8 @@ ACE_Thread_Manager::spawn (ACE_THR_FUNC func, long priority, int grp_id, void *stack, - size_t stack_size) + size_t stack_size, + const char** thr_name) { ACE_TRACE ("ACE_Thread_Manager::spawn"); @@ -684,7 +687,8 @@ ACE_Thread_Manager::spawn (ACE_THR_FUNC func, grp_id, stack, stack_size, - 0) == -1) + 0, + thr_name) == -1) return -1; return grp_id; @@ -702,7 +706,8 @@ ACE_Thread_Manager::spawn_n (size_t n, ACE_Task_Base *task, ACE_hthread_t thread_handles[], void *stack[], - size_t stack_size[]) + size_t stack_size[], + const char* thr_name[]) { ACE_TRACE ("ACE_Thread_Manager::spawn_n"); ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1)); @@ -723,7 +728,8 @@ ACE_Thread_Manager::spawn_n (size_t n, grp_id, stack == 0 ? 0 : stack[i], stack_size == 0 ? ACE_DEFAULT_THREAD_STACKSIZE : stack_size[i], - task) == -1) + task, + thr_name == 0 ? 0 : &thr_name [i]) == -1) return -1; } @@ -743,7 +749,8 @@ ACE_Thread_Manager::spawn_n (ACE_thread_t thread_ids[], void *stack[], size_t stack_size[], ACE_hthread_t thread_handles[], - ACE_Task_Base *task) + ACE_Task_Base *task, + const char* thr_name[]) { ACE_TRACE ("ACE_Thread_Manager::spawn_n"); ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1)); @@ -764,7 +771,8 @@ ACE_Thread_Manager::spawn_n (ACE_thread_t thread_ids[], grp_id, stack == 0 ? 0 : stack[i], stack_size == 0 ? ACE_DEFAULT_THREAD_STACKSIZE : stack_size[i], - task) == -1) + task, + thr_name == 0 ? 0 : &thr_name [i]) == -1) return -1; } @@ -1540,13 +1548,13 @@ ACE_Thread_Manager::wait_grp (int grp_id) // slot. ACE_THR_FUNC_RETURN -ACE_Thread_Manager::exit (ACE_THR_FUNC_RETURN status, int do_thr_exit) +ACE_Thread_Manager::exit (ACE_THR_FUNC_RETURN status, bool do_thread_exit) { ACE_TRACE ("ACE_Thread_Manager::exit"); #if defined (ACE_WIN32) // Remove detached thread handle. - if (do_thr_exit) + if (do_thread_exit) { #if 0 // @@ This callback is now taken care of by TSS_Cleanup. Do we @@ -1570,7 +1578,7 @@ ACE_Thread_Manager::exit (ACE_THR_FUNC_RETURN status, int do_thr_exit) // Find the thread id, but don't use the cache. It might have been // deleted already. - ACE_thread_t id = ACE_OS::thr_self (); + ACE_thread_t const id = ACE_OS::thr_self (); ACE_Thread_Descriptor* td = this->find_thread (id); if (td != 0) { @@ -1580,7 +1588,7 @@ ACE_Thread_Manager::exit (ACE_THR_FUNC_RETURN status, int do_thr_exit) } } - if (do_thr_exit) + if (do_thread_exit) { ACE_Thread::exit (status); // On reasonable systems <ACE_Thread::exit> should not return. diff --git a/ACE/ace/Thread_Manager.h b/ACE/ace/Thread_Manager.h index cd7b477816a..bccfab12e1e 100644 --- a/ACE/ace/Thread_Manager.h +++ b/ACE/ace/Thread_Manager.h @@ -461,22 +461,8 @@ public: */ int close (void); - // The <ACE_thread_t> * argument to each of the <spawn> family member - // functions is interpreted and used as shown in the following - // table. NOTE: the final option, to provide task names, is _only_ - // supported on VxWorks! - // - // Value of ACE_thread_t * argument Use Platforms - // ================================ ========================== ========= - // 0 Not used. All - // non-0 (and points to 0 char * The task name is passed All - // on VxWorks) back in the char *. - // non-0, points to non-0 char * The char * is used as VxWorks only - // the task name. The - // argument is not modified. - /** - * Create a new thread, which executes @a func with argument <arg>. + * Create a new thread, which executes @a func with argument @a arg. * Returns: on success a unique group id that can be used to control * other threads added to the same group. On failure, returns -1. */ @@ -488,10 +474,11 @@ public: long priority = ACE_DEFAULT_THREAD_PRIORITY, int grp_id = -1, void *stack = 0, - size_t stack_size = ACE_DEFAULT_THREAD_STACKSIZE); + size_t stack_size = ACE_DEFAULT_THREAD_STACKSIZE, + const char** thr_name = 0); /** - * Spawn N new threads, which execute @a func with argument <arg>. + * Spawn N new threads, which execute @a func with argument @a arg. * If <thread_ids> != 0 the thread_ids of successfully spawned * threads will be placed into the <thread_ids> buffer (which must * be the same size as @a n). If @a stack != 0 it is assumed to be an @@ -528,10 +515,11 @@ public: ACE_Task_Base *task = 0, ACE_hthread_t thread_handles[] = 0, void *stack[] = 0, - size_t stack_size[] = 0); + size_t stack_size[] = 0, + const char* thr_name[] = 0); /** - * Spawn N new threads, which execute @a func with argument <arg>. + * Spawn N new threads, which execute @a func with argument @a arg. * If <thread_ids> != 0 the thread_ids of successfully spawned * threads will be placed into the <thread_ids> buffer (which must * be the same size as @a n). If @a stack != 0 it is assumed to be an @@ -569,7 +557,8 @@ public: void *stack[] = 0, size_t stack_size[] = 0, ACE_hthread_t thread_handles[] = 0, - ACE_Task_Base *task = 0); + ACE_Task_Base *task = 0, + const char* thr_name[] = 0); /** * Called to clean up when a thread exits. @@ -581,7 +570,7 @@ public: * Should _not_ be called by main thread. */ ACE_THR_FUNC_RETURN exit (ACE_THR_FUNC_RETURN status = 0, - int do_thread_exit = 1); + bool do_thread_exit = true); /** * Block until there are no more threads running in this thread @@ -590,7 +579,7 @@ public: * @param timeout is treated as "absolute" time by default, but this * can be changed to "relative" time by setting the @c * use_absolute_time to false. - * @param abandon_detached_threads If non-0, @c wait() will first + * @param abandon_detached_threads If true, @c wait() will first * check thru its thread list for * threads with THR_DETACHED or * THR_DAEMON flags set and remove @@ -602,11 +591,11 @@ public: * flags are set or not unless it is * called with @c * abandon_detached_threads flag set. - * @param use_absolute_time If non-0 then treat @c timeout as + * @param use_absolute_time If true then treat @c timeout as * absolute time, else relative time. * @return 0 on success * and -1 on failure. * - * NOTE that if this function is called while the @c + * @note If this function is called while the @c * ACE_Object_Manager is shutting down (as a result of program * rundown via @c ACE::fini()), it will not wait for any threads to * complete. If you must wait for threads spawned by this thread @@ -618,7 +607,7 @@ public: bool abandon_detached_threads = false, bool use_absolute_time = true); - /// Join a thread specified by <tid>. Do not wait on a detached thread. + /// Join a thread specified by @a tid. Do not wait on a detached thread. int join (ACE_thread_t tid, ACE_THR_FUNC_RETURN *status = 0); /** @@ -665,8 +654,8 @@ public: int suspend_grp (int grp_id); /** - * True if <t_id> is inactive (i.e., suspended), else false. Always - * return false if <t_id> is not managed by the Thread_Manager. + * True if @a t_id is inactive (i.e., suspended), else false. Always + * return false if @a t_id is not managed by the Thread_Manager. */ int testsuspend (ACE_thread_t t_id); @@ -681,8 +670,8 @@ public: int resume_grp (int grp_id); /** - * True if <t_id> is active (i.e., resumed), else false. Always - * return false if <t_id> is not managed by the Thread_Manager. + * True if @a t_id is active (i.e., resumed), else false. Always + * return false if @a t_id is not managed by the Thread_Manager. */ int testresume (ACE_thread_t t_id); @@ -690,16 +679,18 @@ public: /** * Send @a signum to all stopped threads. Not supported on platforms * that do not have advanced signal support, such as Win32. + */ + int kill_all (int signum); + /** * Send the @a signum to a single thread. Not supported on platforms * that do not have advanced signal support, such as Win32. + */ + int kill (ACE_thread_t, int signum); + /** * Send @a signum to a group of threads, not supported on platforms * that do not have advanced signal support, such as Win32. */ - int kill_all (int signum); - int kill (ACE_thread_t, - int signum); - int kill_grp (int grp_id, - int signum); + int kill_grp (int grp_id, int signum); // = Cancel methods, which provides a cooperative thread-termination mechanism (will not block). /** @@ -718,15 +709,15 @@ public: int cancel_grp (int grp_id, int async_cancel = 0); /** - * True if <t_id> is cancelled, else false. Always return false if - * <t_id> is not managed by the Thread_Manager. + * True if @a t_id is cancelled, else false. Always return false if + * @a t_id is not managed by the Thread_Manager. */ int testcancel (ACE_thread_t t_id); /** - * True if <t_id> has terminated (i.e., is no longer running), + * True if @a t_id has terminated (i.e., is no longer running), * but the slot in the thread manager hasn't been reclaimed yet, - * else false. Always return false if <t_id> is not managed by the + * else false. Always return false if @a t_id is not managed by the * Thread_Manager. */ int testterminate (ACE_thread_t t_id); @@ -773,8 +764,7 @@ public: /** * Send a signal @a signum to all threads in an ACE_Task. */ - int kill_task (ACE_Task_Base *task, - int signum); + int kill_task (ACE_Task_Base *task, int signum); /** * Cancel all threads in an ACE_Task. If <async_cancel> is non-0, @@ -987,7 +977,8 @@ protected: int grp_id = -1, void *stack = 0, size_t stack_size = 0, - ACE_Task_Base *task = 0); + ACE_Task_Base *task = 0, + const char** thr_name = 0); /// Run the registered hooks when the thread exits. void run_thread_exit_hooks (int i); |