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 7extern "C" { 8#include <compat/sys/condvar.h> 9#include <compat/sys/kernel.h> 10} 11 12#include "Condvar.h" 13 14 15void 16conditionInit(struct cv* variable, const char* description) 17{ 18 variable->condition.Init(variable, description); 19} 20 21 22void 23conditionPublish(struct cv* variable, const void* waitChannel, 24 const char* description) 25{ 26 variable->condition.Publish(waitChannel, description); 27} 28 29 30void 31conditionUnpublish(struct cv* variable) 32{ 33 variable->condition.Unpublish(); 34} 35 36 37int 38conditionTimedWait(struct cv* variable, const int timeout) 39{ 40 status_t status = variable->condition.Wait(B_RELATIVE_TIMEOUT, 41 ticks_to_usecs(timeout)); 42 43 if (status != B_OK) 44 status = EWOULDBLOCK; 45 return status; 46} 47 48 49void 50conditionWait(struct cv* variable) 51{ 52 variable->condition.Wait(); 53} 54 55 56void 57conditionNotifyOne(struct cv* variable) 58{ 59 variable->condition.NotifyOne(); 60} 61 62 63int 64publishedConditionTimedWait(const void* waitChannel, const int timeout) 65{ 66 ConditionVariableEntry variableEntry; 67 68 status_t status = variableEntry.Wait(waitChannel, B_RELATIVE_TIMEOUT, 69 ticks_to_usecs(timeout)); 70 71 if (status != B_OK) 72 status = EWOULDBLOCK; 73 return status; 74} 75 76 77void 78publishedConditionNotifyAll(const void* waitChannel) 79{ 80 ConditionVariable::NotifyAll(waitChannel); 81} 82