summaryrefslogtreecommitdiffstats
path: root/src/H5HLdblk.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/H5HLdblk.c')
0 files changed, 0 insertions, 0 deletions
kwb">static pthread_mutex_t qAtomicMutex = PTHREAD_MUTEX_INITIALIZER; static void report_error(int code, const char *where, const char *what) { if (code != 0) qWarning("%s: %s failure: %d", where, what, code); } QMutexPrivate::QMutexPrivate() : contenders(0), wakeup(FALSE) { report_error(pthread_mutex_init(&mutex, NULL), "QMutex", "mutex init"); report_error(pthread_cond_init(&cond, NULL), "QMutex", "cv init"); } QMutexPrivate::~QMutexPrivate() { report_error(pthread_cond_destroy(&cond), "QMutex", "cv destroy"); report_error(pthread_mutex_destroy(&mutex), "QMutex", "mutex destroy"); } void QMutexPrivate::wait() { report_error(pthread_mutex_lock(&mutex), "QMutex::lock", "mutex lock"); int errorCode = 0; while (!wakeup) { errorCode = pthread_cond_wait(&cond, &mutex); if (errorCode) { report_error(errorCode, "QMutex::lock()", "cv wait"); } } wakeup = FALSE; report_error(pthread_mutex_unlock(&mutex), "QMutex::lock", "mutex unlock"); } void QMutexPrivate::wakeUp() { report_error(pthread_mutex_lock(&mutex), "QMutex::unlock", "mutex lock"); wakeup = TRUE; report_error(pthread_cond_signal(&cond), "QMutex::unlock", "cv signal"); report_error(pthread_mutex_unlock(&mutex), "QMutex::unlock", "mutex unlock"); } bool QAtomicInt::testAndSet(int expectedValue,int newValue) { bool returnValue = false; pthread_mutex_lock(&qAtomicMutex); if (m_value == expectedValue) { m_value = newValue; returnValue = true; } pthread_mutex_unlock(&qAtomicMutex); return returnValue; } int QAtomicInt::fetchAndAdd(int valueToAdd) { int returnValue; pthread_mutex_lock(&qAtomicMutex); returnValue = m_value; m_value += valueToAdd; pthread_mutex_unlock(&qAtomicMutex); return returnValue; }