1-- Sleeping on a lock's cell and waking a sleeper on a POSIX system,
2-- through platform/posix.
3
4import core/atomic
5import platform/posix
6
7fixed if compiler.os <> windows then
8 -- Sleep while the cell at `word` holds `expected`, or for nothing.
9 sleep_while: (word: ptr mut atomic.cell(u32), expected: u32) -> none =
10 posix.wait_on(word, expected)
11 end sleep_while
12
13 -- Wake one thread sleeping on the cell at `word`, if any is.
14 wake_one: (word: ptr mut atomic.cell(u32)) -> none =
15 posix.wake_one(word)
16 end wake_one
17end if