| 1 | #pragma once |
|---|---|
| 2 | #include <sync/spinlock.h> |
| 3 | #include <thread/wait.h> |
| 4 | #include <time/timer.h> |
| 5 | |
| 6 | typedef void (*thread_action_callback)(struct thread *woke); |
| 7 | |
| 8 | struct condvar { |
| 9 | struct thread_wait_header waiters; |
| 10 | }; |
| 11 | |
| 12 | enum wake_reason condvar_wait(struct condvar *cv, struct spinlock *lock, |
| 13 | enum irql irql, enum irql *out); |
| 14 | |
| 15 | void condvar_init(struct condvar *cv); |
| 16 | struct thread *condvar_signal(struct condvar *cv); |
| 17 | struct thread *condvar_signal_callback(struct condvar *cv, |
| 18 | thread_action_callback cb); |
| 19 | |
| 20 | void condvar_broadcast_callback(struct condvar *cv, thread_action_callback cb); |
| 21 | |
| 22 | void condvar_broadcast(struct condvar *cv); |
| 23 | |
| 24 | enum wake_reason condvar_wait_timeout(struct condvar *cv, struct spinlock *lock, |
| 25 | time_ms_t timeout_ms, enum irql irql, |
| 26 | enum irql *out); |
| 27 |