ticketlocks
nimony/lib/std/ticketlocks.nim
Ticketlocks for Nimony. A ticket lock is a fair lock, ideal for guaranteed worst case execution times (WCET). This implementation has the advantage that no deinit nor a destructor has to be run making it especially convenient to use.
type TicketLock = object nextTicket: int64 nowServing: int64
proc acquire(L: var TicketLock)proc release(L: var TicketLock)template withLock(a: TicketLock; body: untyped)Acquires the given lock, executes the statements in body and releases the lock after the statements finished executing.