Source Edit

This module contains Nim’s support for locks and condition vars.

Imports

syslocks

Types

  1. Cond = SysCond

Nim condition variable Source Edit

  1. Lock = SysLock

Nim lock; whether this is re-entrant or not is unspecified! Source Edit

Procs

  1. proc `$`(lock: Lock): string {....raises: [], tags: [], forbids: [].}

Source Edit

  1. proc acquire(lock: var Lock) {.inline, ...raises: [], tags: [], forbids: [].}

Acquires the given lock. Source Edit

  1. proc broadcast(cond: var Cond) {.inline, ...raises: [], tags: [], forbids: [].}

Unblocks all threads currently blocked on the specified condition variable cond. Source Edit

  1. proc deinitCond(cond: var Cond) {.inline, ...raises: [], tags: [], forbids: [].}

Frees the resources associated with the condition variable. Source Edit

  1. proc deinitLock(lock: var Lock) {.inline, ...raises: [], tags: [], forbids: [].}

Frees the resources associated with the lock. Source Edit

  1. proc initCond(cond: var Cond) {.inline, ...raises: [], tags: [], forbids: [].}

Initializes the given condition variable. Source Edit

  1. proc initLock(lock: var Lock) {.inline, ...raises: [], tags: [], forbids: [].}

Initializes the given lock. Source Edit

  1. proc release(lock: var Lock) {.inline, ...raises: [], tags: [], forbids: [].}

Releases the given lock. Source Edit

  1. proc signal(cond: var Cond) {.inline, ...raises: [], tags: [], forbids: [].}

Sends a signal to the condition variable cond. Source Edit

  1. proc tryAcquire(lock: var Lock): bool {.inline, ...raises: [], tags: [],
  2. forbids: [].}

Tries to acquire the given lock. Returns true on success. Source Edit

  1. proc wait(cond: var Cond; lock: var Lock) {.inline, ...raises: [], tags: [],
  2. forbids: [].}

Waits on the condition variable cond. Source Edit

Templates

  1. template withLock(a: Lock; body: untyped)

Acquires the given lock, executes the statements in body and releases the lock after the statements finish executing. Source Edit