Raw operating-system-thread wait primitive over one supplied mutex. wait temporarily releases that mutex, waits, and reacquires the same mode before return.
ConditionVariable
Methods
INIT
(--) Resets the condition variable to the initial empty-waiter state.wait
(mutex time shared -- signaled) Waits on the supplied mutex. The lock is released while waiting and reacquired in the same mode before return. The result is TRUE when waiting ends before timeout and FALSE when a finite timeout expires.Preconditions
wakeAll
(--) Releases every thread that is already waiting at that moment.wakeOne
(--) Releases one thread that is already waiting at that moment.Remarks
- A newly constructed
ConditionVariablestarts in the initialized empty-waiter state.
Wait semantics
waitborrows the supplied mutex.- With
sharedequal toFALSE,waittemporarily releases one exclusive acquisition and reacquires exclusive mode before return. - With
sharedequal toTRUE,waittemporarily releases one shared acquisition and reacquires shared mode before return. timeis measured in milliseconds.timeequal to-1selects an infinite wait.waitreturnsTRUEwhen waiting ends before timeout andFALSEonly when a finite timeout expires.wakeOneaffects at most one thread that is already waiting, andwakeAllaffects every thread that is already waiting.- No wake is remembered for later waiters.
wakeAllandwakeOnereturn no status value.
Examples
Windows wait example
"String" use
"control.Int32" use
"windows/ConditionVariable" use
"windows/Mutex" use
{} Int32 {} [
mutex: Mutex;
condition: ConditionVariable;
@mutex.lock
result: @mutex 0 FALSE @condition.wait;
@mutex.unlock
("wait=" result LF) printList
0
] "main" exportFunction
Expected Output
wait=FALSE
See also
- windows/Mutex: SRW lock wrapper with exclusive and shared locking.
- lockGuard: Scope-based locking and unlocking helpers.
- sync/Event: Persistent event state with clear, set, wait, wake, and wakeOne.
- sync/Signal: Wait queue with wake and wakeOne operations.
- sync/sync: Cross-platform scheduling, sleep, time, IPv4 formatting, and TCP helpers.