static int fence_id;
struct lp_fence *fence = CALLOC_STRUCT(lp_fence);
+ if (!fence)
+ return NULL;
+
pipe_reference_init(&fence->reference, 1);
- pipe_mutex_init(fence->mutex);
- pipe_condvar_init(fence->signalled);
+ (void) mtx_init(&fence->mutex, mtx_plain);
+ cnd_init(&fence->signalled);
fence->id = fence_id++;
fence->rank = rank;
if (LP_DEBUG & DEBUG_FENCE)
debug_printf("%s %d\n", __FUNCTION__, fence->id);
- pipe_mutex_destroy(fence->mutex);
- pipe_condvar_destroy(fence->signalled);
+ mtx_destroy(&fence->mutex);
+ cnd_destroy(&fence->signalled);
FREE(fence);
}
if (LP_DEBUG & DEBUG_FENCE)
debug_printf("%s %d\n", __FUNCTION__, fence->id);
- pipe_mutex_lock(fence->mutex);
+ mtx_lock(&fence->mutex);
fence->count++;
assert(fence->count <= fence->rank);
/* Wakeup all threads waiting on the mutex:
*/
- pipe_condvar_broadcast(fence->signalled);
+ cnd_broadcast(&fence->signalled);
- pipe_mutex_unlock(fence->mutex);
+ mtx_unlock(&fence->mutex);
}
boolean
if (LP_DEBUG & DEBUG_FENCE)
debug_printf("%s %d\n", __FUNCTION__, f->id);
- pipe_mutex_lock(f->mutex);
+ mtx_lock(&f->mutex);
assert(f->issued);
while (f->count < f->rank) {
- pipe_condvar_wait(f->signalled, f->mutex);
+ cnd_wait(&f->signalled, &f->mutex);
}
- pipe_mutex_unlock(f->mutex);
+ mtx_unlock(&f->mutex);
}