From: Kefu Chai Date: Mon, 22 Jul 2019 06:49:49 +0000 (+0800) Subject: common/Cond.h: remove Cond X-Git-Tag: v15.1.0~1971^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=57a3254f3d9274099e5e36e1638b5c4e2d2f4bbf;p=ceph.git common/Cond.h: remove Cond as it's replaced by ceph::condition_variable. Signed-off-by: Kefu Chai --- diff --git a/src/common/Cond.h b/src/common/Cond.h index 3afe159b22f4..ecbd57334963 100644 --- a/src/common/Cond.h +++ b/src/common/Cond.h @@ -17,108 +17,9 @@ #define CEPH_COND_H #include "common/Clock.h" -#include "common/Mutex.h" +#include "common/ceph_mutex.h" #include "include/Context.h" -class Cond { - // my bits - pthread_cond_t _c; - - Mutex *waiter_mutex; - - // don't allow copying. - void operator=(Cond &C); - Cond(const Cond &C); - - public: - Cond() : waiter_mutex(NULL) { - int r = pthread_cond_init(&_c,NULL); - ceph_assert(r == 0); - } - virtual ~Cond() { - pthread_cond_destroy(&_c); - } - - int Wait(Mutex &mutex) { - // make sure this cond is used with one mutex only - ceph_assert(waiter_mutex == NULL || waiter_mutex == &mutex); - waiter_mutex = &mutex; - - ceph_assert(mutex.is_locked()); - - mutex._pre_unlock(); - int r = pthread_cond_wait(&_c, &mutex._m); - mutex._post_lock(); - return r; - } - - int WaitUntil(Mutex &mutex, utime_t when) { - // make sure this cond is used with one mutex only - ceph_assert(waiter_mutex == NULL || waiter_mutex == &mutex); - waiter_mutex = &mutex; - - ceph_assert(mutex.is_locked()); - - struct timespec ts; - when.to_timespec(&ts); - - mutex._pre_unlock(); - int r = pthread_cond_timedwait(&_c, &mutex._m, &ts); - mutex._post_lock(); - - return r; - } - - int WaitInterval(Mutex &mutex, utime_t interval) { - utime_t when = ceph_clock_now(); - when += interval; - return WaitUntil(mutex, when); - } - - template - int WaitInterval(Mutex &mutex, Duration interval) { - ceph::real_time when(ceph::real_clock::now()); - when += interval; - - struct timespec ts = ceph::real_clock::to_timespec(when); - - mutex._pre_unlock(); - int r = pthread_cond_timedwait(&_c, &mutex._m, &ts); - mutex._post_lock(); - - return r; - } - - int SloppySignal() { - int r = pthread_cond_broadcast(&_c); - return r; - } - int Signal() { - // make sure signaler is holding the waiter's lock. - ceph_assert(waiter_mutex == NULL || - waiter_mutex->is_locked()); - - int r = pthread_cond_broadcast(&_c); - return r; - } - int SignalOne() { - // make sure signaler is holding the waiter's lock. - ceph_assert(waiter_mutex == NULL || - waiter_mutex->is_locked()); - - int r = pthread_cond_signal(&_c); - return r; - } - int SignalAll() { - // make sure signaler is holding the waiter's lock. - ceph_assert(waiter_mutex == NULL || - waiter_mutex->is_locked()); - - int r = pthread_cond_broadcast(&_c); - return r; - } -}; - /** * context to signal a cond *