mirror of
https://github.com/QB64-Phoenix-Edition/QB64pe.git
synced 2024-07-01 13:50:36 +00:00
Use mutex guard in completion implementation
This commit is contained in:
parent
298331e490
commit
94c2b56b69
|
@ -17,17 +17,15 @@ void completion_clear(struct completion *comp) {
|
|||
}
|
||||
|
||||
void completion_wait(struct completion *comp) {
|
||||
libqb_mutex_lock(comp->mutex);
|
||||
libqb_mutex_guard guard(comp->mutex);
|
||||
|
||||
while (!comp->finished)
|
||||
libqb_condvar_wait(comp->var, comp->mutex);
|
||||
|
||||
libqb_mutex_unlock(comp->mutex);
|
||||
}
|
||||
|
||||
void completion_finish(struct completion *comp) {
|
||||
libqb_mutex_lock(comp->mutex);
|
||||
libqb_mutex_guard guard(comp->mutex);
|
||||
|
||||
comp->finished = 1;
|
||||
libqb_condvar_broadcast(comp->var);
|
||||
libqb_mutex_unlock(comp->mutex);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue