134 files changed, 31073 insertions, 30287 deletions
diff --git a/tvapi/libtv/tvutils/CCondition.h b/tvapi/libtv/tvutils/CCondition.h index 0505629..d4ed263 100644 --- a/tvapi/libtv/tvutils/CCondition.h +++ b/tvapi/libtv/tvutils/CCondition.h @@ -15,25 +15,25 @@ typedef long long nsecs_t; class CCondition { public: - enum { - PRIVATE = 0, - SHARED = 1 - }; + enum { + PRIVATE = 0, + SHARED = 1 + }; - CCondition(); - CCondition(int type); - ~CCondition(); - // Wait on the condition variable. Lock the mutex before calling. - int wait(CMutex &mutex); - // same with relative timeout - int waitRelative(CMutex &mutex, long sec); - // Signal the condition variable, allowing one thread to continue. - void signal(); - // Signal the condition variable, allowing all threads to continue. - void broadcast(); + CCondition(); + CCondition(int type); + ~CCondition(); + // Wait on the condition variable. Lock the mutex before calling. + int wait(CMutex &mutex); + // same with relative timeout + int waitRelative(CMutex &mutex, long sec); + // Signal the condition variable, allowing one thread to continue. + void signal(); + // Signal the condition variable, allowing all threads to continue. + void broadcast(); private: - pthread_cond_t mCond; + pthread_cond_t mCond; }; @@ -42,49 +42,49 @@ private: inline CCondition::CCondition() { - pthread_cond_init(&mCond, NULL); + pthread_cond_init(&mCond, NULL); } inline CCondition::CCondition(int type) { - if (type == SHARED) { - pthread_condattr_t attr; - pthread_condattr_init(&attr); - pthread_condattr_setpshared(&attr, PTHREAD_PROCESS_SHARED); - pthread_cond_init(&mCond, &attr); - pthread_condattr_destroy(&attr); - } else { - pthread_cond_init(&mCond, NULL); - } + if (type == SHARED) { + pthread_condattr_t attr; + pthread_condattr_init(&attr); + pthread_condattr_setpshared(&attr, PTHREAD_PROCESS_SHARED); + pthread_cond_init(&mCond, &attr); + pthread_condattr_destroy(&attr); + } else { + pthread_cond_init(&mCond, NULL); + } } inline CCondition::~CCondition() { - pthread_cond_destroy(&mCond); + pthread_cond_destroy(&mCond); } inline int CCondition::wait(CMutex &mutex) { - return -pthread_cond_wait(&mCond, &mutex.mMutex); + return -pthread_cond_wait(&mCond, &mutex.mMutex); } inline int CCondition::waitRelative(CMutex &mutex, long msec) { - struct timespec ts; - long _nanoSec = 1000000000; - int _sec = msec / 1000; - long _nsec = (msec - 1000 * _sec) * 1000000; - clock_gettime(CLOCK_REALTIME, &ts); - ts.tv_sec += _sec; - ts.tv_nsec += _nsec; - if (ts.tv_nsec > _nanoSec) { - ts.tv_nsec %= _nanoSec; - ts.tv_sec++; - } - return -pthread_cond_timedwait(&mCond, &mutex.mMutex, &ts); + struct timespec ts; + long _nanoSec = 1000000000; + int _sec = msec / 1000; + long _nsec = (msec - 1000 * _sec) * 1000000; + clock_gettime(CLOCK_REALTIME, &ts); + ts.tv_sec += _sec; + ts.tv_nsec += _nsec; + if (ts.tv_nsec > _nanoSec) { + ts.tv_nsec %= _nanoSec; + ts.tv_sec++; + } + return -pthread_cond_timedwait(&mCond, &mutex.mMutex, &ts); } inline void CCondition::signal() { - pthread_cond_signal(&mCond); + pthread_cond_signal(&mCond); } inline void CCondition::broadcast() { - pthread_cond_broadcast(&mCond); + pthread_cond_broadcast(&mCond); } #endif |