From 45ab2293681212c41023c26d338c42a3456590a7 Mon Sep 17 00:00:00 2001 From: elliott_c Date: Fri, 18 Apr 2003 18:38:44 +0000 Subject: ChangeLogTag: Fri Apr 18 13:35:51 2003 Chad Elliott --- ChangeLog | 7 +++++++ ace/OS.cpp | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ace/OS.i | 6 ++++-- 3 files changed, 75 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index fb8cb5a11fa..ec211e8c980 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +Fri Apr 18 13:35:51 2003 Chad Elliott + + * ace/OS.i: + * ace/OS.cpp: + + Added an implementation of ACE_OS::thr_join() for VxWorks. + Fri Apr 18 12:24:02 2003 Chad Elliott * bin/MakeProjectCreator/modules/Driver.pm: diff --git a/ace/OS.cpp b/ace/OS.cpp index 801ab5d246d..ef9c4723c2f 100644 --- a/ace/OS.cpp +++ b/ace/OS.cpp @@ -821,6 +821,70 @@ ACE_OS::gethostbyname_r (const char *name, hostent *result, *h_errnop = errno; return result; } + +// Leave this in the global scope to allow +// users to adjust the delay value. +int ACE_THR_JOIN_DELAY = 5; + +int +ACE_OS::thr_join (ACE_hthread_t thr_handle, + ACE_THR_FUNC_RETURN *status) +{ + // We can't get the status of the thread + if (status != 0) + { + *status = 0; + } + + // This method can not support joining all threads + if (ACE_OS::thr_cmp (thr_handle, ACE_OS::NULL_hthread)) + { + ACE_NOTSUP_RETURN (-1); + } + + int retval = ESRCH; + ACE_hthread_t current; + ACE_OS::thr_self (current); + + // Make sure we are not joining ourself + if (ACE_OS::thr_cmp (thr_handle, current)) + { + retval = EDEADLK; + } + else + { + // Whether the task exists or not + // we will return a successful value + retval = 0; + + // Verify that the task id still exists + while (taskIdVerify (thr_handle) == OK) + { + // Wait a bit to see if the task is still active. + ACE_OS::sleep (ACE_THR_JOIN_DELAY); + } + } + + // Adapt the return value into errno and return value. + // The ACE_ADAPT_RETVAL macro doesn't exactly do what + // we need to do here, so we do it manually. + if (retval != 0) + { + errno = retval; + retval = -1; + } + + return retval; +} + +int +ACE_OS::thr_join (ACE_thread_t waiter_id, + ACE_thread_t *thr_id, + ACE_THR_FUNC_RETURN *status) +{ + thr_id = 0; + return ACE_OS::thr_join (taskNameToId (waiter_id), status); +} #endif /* VXWORKS */ void diff --git a/ace/OS.i b/ace/OS.i index b2674e190b8..6c1ce286e30 100644 --- a/ace/OS.i +++ b/ace/OS.i @@ -6741,6 +6741,7 @@ ACE_OS::thr_getspecific (ACE_thread_key_t key, void **data) #endif /* ACE_HAS_THREADS */ } +#if !defined (VXWORKS) ACE_INLINE int ACE_OS::thr_join (ACE_hthread_t thr_handle, ACE_THR_FUNC_RETURN *status) @@ -6797,7 +6798,7 @@ ACE_OS::thr_join (ACE_hthread_t thr_handle, } ACE_FAIL_RETURN (-1); /* NOTREACHED */ -# elif defined (VXWORKS) || defined (ACE_PSOS) +# elif defined (ACE_PSOS) ACE_UNUSED_ARG (thr_handle); ACE_UNUSED_ARG (status); ACE_NOTSUP_RETURN (-1); @@ -6845,7 +6846,7 @@ ACE_OS::thr_join (ACE_thread_t waiter_id, // This could be implemented if the DLL-Main function or the // task exit base class some log the threads which have exited ACE_NOTSUP_RETURN (-1); -# elif defined (VXWORKS) || defined (ACE_PSOS) +# elif defined (ACE_PSOS) ACE_UNUSED_ARG (waiter_id); ACE_UNUSED_ARG (thr_id); ACE_UNUSED_ARG (status); @@ -6858,6 +6859,7 @@ ACE_OS::thr_join (ACE_thread_t waiter_id, ACE_NOTSUP_RETURN (-1); #endif /* ACE_HAS_THREADS */ } +#endif /* !VXWORKS */ ACE_INLINE int ACE_OS::thr_setcancelstate (int new_state, int *old_state) -- cgit v1.2.1