diff options
author | Benoit Foucher <benoit@zeroc.com> | 2004-05-21 22:17:44 +0000 |
---|---|---|
committer | Benoit Foucher <benoit@zeroc.com> | 2004-05-21 22:17:44 +0000 |
commit | d3415d1494f72bd21e67ec0905f26af2880cecef (patch) | |
tree | 7f60c1ebf1c5d138a55587dd72ea9fece096f918 /cpp/src/IceUtil/CountDownLatch.cpp | |
parent | Fixed ICC release problem (diff) | |
download | ice-d3415d1494f72bd21e67ec0905f26af2880cecef.tar.bz2 ice-d3415d1494f72bd21e67ec0905f26af2880cecef.tar.xz ice-d3415d1494f72bd21e67ec0905f26af2880cecef.zip |
Cond variable broadcast is done w/ mutex locked on Apple
Diffstat (limited to 'cpp/src/IceUtil/CountDownLatch.cpp')
-rw-r--r-- | cpp/src/IceUtil/CountDownLatch.cpp | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/cpp/src/IceUtil/CountDownLatch.cpp b/cpp/src/IceUtil/CountDownLatch.cpp index 0fcca4e3f0b..c0f466e02bc 100644 --- a/cpp/src/IceUtil/CountDownLatch.cpp +++ b/cpp/src/IceUtil/CountDownLatch.cpp @@ -89,6 +89,23 @@ IceUtil::CountDownLatch::countDown() { broadcast = true; } +#if defined(__APPLE__) + // + // On MacOS X we do the broadcast with the mutex held. This seems to be necessary to prevent the + // broadcast call to hang (spining in an infinite loop). + // + if(broadcast) + { + int rc = pthread_cond_broadcast(&_cond); + if(rc != 0) + { + pthread_mutex_unlock(&_mutex); + throw ThreadSyscallException(__FILE__, __LINE__, rc); + } + } + unlock(); + +#else unlock(); if(broadcast) @@ -96,11 +113,12 @@ IceUtil::CountDownLatch::countDown() int rc = pthread_cond_broadcast(&_cond); if(rc != 0) { - pthread_mutex_unlock(&_mutex); throw ThreadSyscallException(__FILE__, __LINE__, rc); } } #endif + +#endif } int |