Implement a lock template in locks module.
This commit is contained in:
parent
8dade039d7
commit
f0341979bd
1 changed files with 8 additions and 0 deletions
|
|
@ -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()
|
||||
Loading…
Add table
Add a link
Reference in a new issue