1/* 2 * Copyright 2022, Haiku, Inc. All rights reserved. 3 * Distributed under the terms of the MIT license. 4 */ 5 6extern "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 16int 17msleep(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 30void 31wakeup(void* identifier) 32{ 33 ConditionVariable::NotifyAll(identifier, B_OK); 34} 35 36 37void 38wakeup_one(void* identifier) 39{ 40 ConditionVariable::NotifyOne(identifier, B_OK); 41} 42