46 #define MIN(a,b) ((a)<(b)?(a):(b)) 51 qWarning(
"%s: %s failure: %d", where, what, code);
67 code = pthread_cond_wait(&cond, &mutex);
68 if (code == 0 && wakeups == 0)
87 report_error(pthread_mutex_unlock(&mutex),
"QWaitCondition::wait()",
"mutex unlock");
95 report_error(pthread_mutex_init(&
d->mutex, NULL),
"QWaitCondition",
"mutex init");
96 report_error(pthread_cond_init(&
d->cond, NULL),
"QWaitCondition",
"cv init");
97 d->waiters =
d->wakeups = 0;
103 report_error(pthread_cond_destroy(&
d->cond),
"QWaitCondition",
"cv destroy");
104 report_error(pthread_mutex_destroy(&
d->mutex),
"QWaitCondition",
"mutex destroy");
110 report_error(pthread_mutex_lock(&
d->mutex),
"QWaitCondition::wakeOne()",
"mutex lock");
111 d->wakeups =
MIN(
d->wakeups + 1,
d->waiters);
112 report_error(pthread_cond_signal(&
d->cond),
"QWaitCondition::wakeOne()",
"cv signal");
113 report_error(pthread_mutex_unlock(&
d->mutex),
"QWaitCondition::wakeOne()",
"mutex unlock");
118 report_error(pthread_mutex_lock(&
d->mutex),
"QWaitCondition::wakeAll()",
"mutex lock");
119 d->wakeups =
d->waiters;
120 report_error(pthread_cond_broadcast(&
d->cond),
"QWaitCondition::wakeAll()",
"cv broadcast");
121 report_error(pthread_mutex_unlock(&
d->mutex),
"QWaitCondition::wakeAll()",
"mutex unlock");
128 report_error(pthread_mutex_lock(&
d->mutex),
"QWaitCondition::wait()",
"mutex lock");
void qWarning(const char *msg,...)
CodeOutputInterface * code
static void report_error(int code, const char *where, const char *what)