mirror of
https://github.com/nim-lang/Nim.git
synced 2025-12-31 18:32:11 +00:00
Implement a lock template in locks module.
This commit is contained in:
@@ -54,3 +54,11 @@ proc wait*(cond: var Cond, lock: var Lock) {.inline.} =
|
||||
proc signal*(cond: var Cond) {.inline.} =
|
||||
## sends a signal to the condition variable `cond`.
|
||||
signalSysCond(cond)
|
||||
|
||||
template lock*(a: Lock, body: stmt) =
|
||||
a.acquire()
|
||||
{.locks: [a].}:
|
||||
try:
|
||||
body
|
||||
finally:
|
||||
a.release()
|
||||
Reference in New Issue
Block a user