Module locks

This module contains Nimrod's support for locks and condition vars. If the symbol preventDeadlocks is defined (compiled with -d:preventDeadlocks) special logic is added to every acquire, tryAcquire and release action that ensures at runtime that no deadlock can occur. This is achieved by forcing a thread to release its locks should it be part of a deadlock. This thread then re-acquires its locks and proceeds.

Types

TLock* = TSysLock
Nimrod lock; whether this is re-entrant or not is unspecified! However, compilation in preventDeadlocks-mode guarantees re-entrancy.
TCond* = TSysCond
Nimrod condition variable

Vars

deadlocksPrevented*: int
counts the number of times a deadlock has been prevented

Consts

maxLocksPerThread* = 10
max number of locks a thread can hold at the same time; this limit is only relevant when compiled with -d:preventDeadlocks.

Procs

proc InitLock*(lock: var TLock) {.inline.}
Initializes the given lock.
proc DeinitLock*(lock: var TLock) {.inline.}
Frees the resources associated with the lock.
proc TryAcquire*(lock: var TLock): bool
Tries to acquire the given lock. Returns true on success.
proc Acquire*(lock: var TLock)
Acquires the given lock.
proc Release*(lock: var TLock)
Releases the given lock.
proc InitCond*(cond: var TCond) {.inline.}
Initializes the given condition variable.
proc DeinitCond*(cond: var TCond) {.inline.}
Frees the resources associated with the lock.
proc wait*(cond: var TCond; lock: var TLock) {.inline.}
waits on the condition variable cond.
proc signal*(cond: var TCond) {.inline.}
sends a signal to the condition variable cond.
Generated: 2012-09-23 21:47:54 UTC