Thread module

wait_for

procedure2 overloadsSource

Takes one count from the semaphore, waiting for signal if there is none. The result says whether it got one: .SUCCESS, .TIMEOUT or .ERROR.

wait_for :: (s: *Semaphore, milliseconds: s32 = -1) -> Wait_For_Result

Takes one count from the semaphore, waiting for signal if there is none. The result says whether it got one: .SUCCESS, .TIMEOUT or .ERROR.

Parameters

milliseconds: s32 = -1
how long to wait at most. 0 only tries; -1 waits as long as it takes.

Returns

wait_for :: (s: *Semaphore, milliseconds: s32 = -1) -> Wait_For_Result

Takes one count from the semaphore, waiting for signal if there is none. The result says whether it got one: .SUCCESS, .TIMEOUT or .ERROR.

Parameters

milliseconds: s32 = -1
how long to wait at most. 0 only tries; -1 waits as long as it takes.

Returns

Example↗
semaphore: Semaphore;
init(*semaphore);
defer destroy(*semaphore);
assert(wait_for(*semaphore, 10) == .TIMEOUT);

See also