Lock¶
Import: import system.core;
Lock¶
Reentrant mutual-exclusion lock for @shared critical sections.
host_acquire¶
Waits until the synchronization object can be acquired.
host_release¶
Releases the synchronization object after acquisition.
host_try_acquire¶
Attempts acquisition without waiting; returns whether it succeeded.
host_try_acquire_for¶
Attempts acquisition for up to timeout_ms milliseconds.
acquire¶
Reentrant: the same thread may call acquire again before releasing (matching lock (obj) { ... }'s own semantics), and must call release the same number of times to fully release it.
try_acquire¶
One-shot acquire: returns true on success (including a reentrant bump), false if another thread currently holds the lock.
try_acquire_for¶
Waits up to timeout_ms milliseconds to acquire. timeout_ms <= 0 is a single try. Best-effort under contention: spurious wakes do not shrink the remaining wait budget.
release¶
Releasing without ownership is a runtime panic, including release of an unheld lock.