1/* 2 * Copyright 2009 Colin G��nther, coling@gmx.de. 3 * All rights reserved. Distributed under the terms of the MIT License. 4 */ 5 6 7#include <compat/sys/mutex.h> 8#include <compat/sys/condvar.h> 9 10#include "Condvar.h" 11 12 13void cv_init(struct cv* variable, const char* description) 14{ 15 conditionInit(variable, description); 16} 17 18 19void cv_signal(struct cv* variable) 20{ 21 conditionNotifyOne(variable); 22} 23 24 25int cv_timedwait(struct cv* variable, struct mtx* mutex, int timeout) 26{ 27 int status; 28 29 mtx_unlock(mutex); 30 status = conditionTimedWait(variable, timeout); 31 mtx_lock(mutex); 32 33 return status; 34} 35 36 37void cv_wait(struct cv* variable, struct mtx* mutex) 38{ 39 mtx_unlock(mutex); 40 conditionWait(variable); 41 mtx_lock(mutex); 42} 43