balls/semaphores

Source   Edit  

Types

Semaphore = object
Source   Edit  

Procs

proc `=copy`(s: var Semaphore; e: Semaphore) {.
    error: "semaphores cannot be copied".}
Source   Edit  
proc `=destroy`(s: var Semaphore) {....raises: [], tags: [], forbids: [].}
Source   Edit  
proc acquire(s: var Semaphore) {....raises: [], tags: [], forbids: [].}
adhoc acquire of semaphore's lock Source   Edit  
proc available(s: var Semaphore): int {....raises: [], tags: [], forbids: [].}
blocking count of s Source   Edit  
proc dec(s: var Semaphore) {....raises: [], tags: [], forbids: [].}
blocking adhoc adjustment of the semaphore Source   Edit  
proc hash(s: var Semaphore): Hash {....raises: [], tags: [], forbids: [].}
whatfer inclusion in a table, etc. Source   Edit  
proc inc(s: var Semaphore) {....raises: [], tags: [], forbids: [].}
blocking adhoc adjustment of the semaphore Source   Edit  
proc initSemaphore(s: var Semaphore; count: int = 0) {....raises: [], tags: [],
    forbids: [].}
make a semaphore available for use Source   Edit  
proc release(s: var Semaphore) {....raises: [], tags: [], forbids: [].}
adhoc release of semaphore's lock Source   Edit  
proc signal(s: var Semaphore) {....raises: [], tags: [], forbids: [].}
blocking signal of s; increments semaphore Source   Edit  
proc wait(s: var Semaphore) {....raises: [], tags: [], forbids: [].}
blocking wait on s Source   Edit  

Templates

template isReady(s: var Semaphore): untyped
blocking true if s is ready Source   Edit  
template withLock(s: var Semaphore; logic: untyped)
run the logic while holding the semaphore s's lock Source   Edit  
template withSemaphore(s: var Semaphore; logic: typed): untyped
wait for the semaphore s, run the logic, and signal it Source   Edit