1 /* 2 * Copyright 2022, Haiku, Inc. All rights reserved. 3 * Distributed under the terms of the MIT license. 4 */ 5 6 extern "C" { 7 #include <compat/sys/systm.h> 8 #include <compat/sys/kernel.h> 9 #include <compat/sys/mutex.h> 10 #include <compat/sys/condvar.h> 11 } 12 13 #include <condition_variable.h> 14 15 16 int 17 msleep(void* identifier, struct mtx* mutex, int priority, 18 const char* description, int timeout) 19 { 20 struct cv channel; 21 __cv_ConditionVariable(&channel)->Publish(identifier, description); 22 23 int status = cv_timedwait(&channel, mutex, timeout); 24 25 __cv_ConditionVariable(&channel)->Unpublish(); 26 return status; 27 } 28 29 30 void 31 wakeup(void* identifier) 32 { 33 ConditionVariable::NotifyAll(identifier, B_OK); 34 } 35 36 37 void 38 wakeup_one(void* identifier) 39 { 40 ConditionVariable::NotifyOne(identifier, B_OK); 41 } 42