summaryrefslogtreecommitdiff
path: root/cpp/src/qpid/sys/Condition.h
diff options
context:
space:
mode:
authorAndrew Stitcher <astitcher@apache.org>2007-05-22 15:18:08 +0000
committerAndrew Stitcher <astitcher@apache.org>2007-05-22 15:18:08 +0000
commitf646350b5e59ccf49f1253bd55f98d062769f2ee (patch)
treeba8143aa842ced96eaa450cc236a96abdd8b9c05 /cpp/src/qpid/sys/Condition.h
parentb8f00ac2a358a02d0cdae2dc098f2bacb2af44d5 (diff)
downloadqpid-python-f646350b5e59ccf49f1253bd55f98d062769f2ee.tar.gz
* Split apart platform (threading etc.) from network io
you can now use a posix platform implementation by configuring --disable-apr-platform * Changed Time classes to distinguish between absolute times (AbsTime) and durations (Duration). This should avoid bugs caused by confusing the two types of time. git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@540608 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src/qpid/sys/Condition.h')
-rw-r--r--cpp/src/qpid/sys/Condition.h103
1 files changed, 3 insertions, 100 deletions
diff --git a/cpp/src/qpid/sys/Condition.h b/cpp/src/qpid/sys/Condition.h
index 455b179683..961c15e1ee 100644
--- a/cpp/src/qpid/sys/Condition.h
+++ b/cpp/src/qpid/sys/Condition.h
@@ -22,107 +22,10 @@
*
*/
-#include <sys/errno.h>
-#include <boost/noncopyable.hpp>
-#include "Mutex.h"
-#include "Time.h"
-
-#ifdef USE_APR
-#include <apr_thread_cond.h>
-#endif
-
-namespace qpid {
-namespace sys {
-
-/**
- * A condition variable for thread synchronization.
- */
-class Condition
-{
- public:
- inline Condition();
- inline ~Condition();
- inline void wait(Mutex&);
- inline bool wait(Mutex&, const Time& absoluteTime);
- inline void notify();
- inline void notifyAll();
-
- private:
-#ifdef USE_APR
- apr_thread_cond_t* condition;
+#ifdef USE_APR_PLATFORM
+#include "apr/Condition.h"
#else
- pthread_cond_t condition;
+#include "posix/Condition.h"
#endif
-};
-
-
-// APR ================================================================
-#ifdef USE_APR
-
-Condition::Condition() {
- CHECK_APR_SUCCESS(apr_thread_cond_create(&condition, APRPool::get()));
-}
-
-Condition::~Condition() {
- CHECK_APR_SUCCESS(apr_thread_cond_destroy(condition));
-}
-
-void Condition::wait(Mutex& mutex) {
- CHECK_APR_SUCCESS(apr_thread_cond_wait(condition, mutex.mutex));
-}
-
-bool Condition::wait(Mutex& mutex, const Time& absoluteTime){
- // APR uses microseconds.
- apr_status_t status =
- apr_thread_cond_timedwait(
- condition, mutex.mutex, absoluteTime/TIME_USEC);
- if(status != APR_TIMEUP) CHECK_APR_SUCCESS(status);
- return status == 0;
-}
-
-void Condition::notify(){
- CHECK_APR_SUCCESS(apr_thread_cond_signal(condition));
-}
-
-void Condition::notifyAll(){
- CHECK_APR_SUCCESS(apr_thread_cond_broadcast(condition));
-}
-
-#else
-// POSIX ================================================================
-
-Condition::Condition() {
- QPID_POSIX_THROW_IF(pthread_cond_init(&condition, 0));
-}
-
-Condition::~Condition() {
- QPID_POSIX_THROW_IF(pthread_cond_destroy(&condition));
-}
-
-void Condition::wait(Mutex& mutex) {
- QPID_POSIX_THROW_IF(pthread_cond_wait(&condition, &mutex.mutex));
-}
-
-bool Condition::wait(Mutex& mutex, const Time& absoluteTime){
- struct timespec ts;
- toTimespec(ts, absoluteTime);
- int status = pthread_cond_timedwait(&condition, &mutex.mutex, &ts);
- if (status != 0) {
- if (status == ETIMEDOUT) return false;
- throw QPID_POSIX_ERROR(status);
- }
- return true;
-}
-
-void Condition::notify(){
- QPID_POSIX_THROW_IF(pthread_cond_signal(&condition));
-}
-
-void Condition::notifyAll(){
- QPID_POSIX_THROW_IF(pthread_cond_broadcast(&condition));
-}
-#endif /*USE_APR*/
-
-}}
#endif /*!_sys_Condition_h*/