summaryrefslogtreecommitdiff
path: root/ace/OS.cpp
diff options
context:
space:
mode:
authorelliott_c <elliott_c@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2003-04-18 18:38:44 +0000
committerelliott_c <elliott_c@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2003-04-18 18:38:44 +0000
commit5ddda7805d5fe0d78e7feec8fb93f95529940538 (patch)
tree8dd889a7f2685c5c908971de2239263051a9ce53 /ace/OS.cpp
parent4de574266420b2473a0bacdb13e67d0343a2d216 (diff)
downloadATCD-5ddda7805d5fe0d78e7feec8fb93f95529940538.tar.gz
ChangeLogTag: Fri Apr 18 13:35:51 2003 Chad Elliott <elliott_c@ociweb.com>
Diffstat (limited to 'ace/OS.cpp')
-rw-r--r--ace/OS.cpp64
1 files changed, 64 insertions, 0 deletions
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