[std/locks]remove workaround for withLock (#17772)
Ref #6113 and #6049 The workaround for generics instantiation is unnecessary. It seems to be fixed by another PR I guess. The test still works. So the changes should be harmless. https://github.com/nim-lang/Nim/blob/devel/tests/stdlib/tlocks.nim I also add some inline pragmas.
This commit is contained in:
parent
f8038af5ec
commit
cedbc7035d
1 changed files with 3 additions and 4 deletions
|
|
@ -42,16 +42,16 @@ proc deinitLock*(lock: var Lock) {.inline.} =
|
||||||
## Frees the resources associated with the lock.
|
## Frees the resources associated with the lock.
|
||||||
deinitSys(lock)
|
deinitSys(lock)
|
||||||
|
|
||||||
proc tryAcquire*(lock: var Lock): bool =
|
proc tryAcquire*(lock: var Lock): bool {.inline.} =
|
||||||
## Tries to acquire the given lock. Returns `true` on success.
|
## Tries to acquire the given lock. Returns `true` on success.
|
||||||
result = tryAcquireSys(lock)
|
result = tryAcquireSys(lock)
|
||||||
|
|
||||||
proc acquire*(lock: var Lock) =
|
proc acquire*(lock: var Lock) {.inline.} =
|
||||||
## Acquires the given lock.
|
## Acquires the given lock.
|
||||||
when not defined(js):
|
when not defined(js):
|
||||||
acquireSys(lock)
|
acquireSys(lock)
|
||||||
|
|
||||||
proc release*(lock: var Lock) =
|
proc release*(lock: var Lock) {.inline.} =
|
||||||
## Releases the given lock.
|
## Releases the given lock.
|
||||||
when not defined(js):
|
when not defined(js):
|
||||||
releaseSys(lock)
|
releaseSys(lock)
|
||||||
|
|
@ -76,7 +76,6 @@ proc signal*(cond: var Cond) {.inline.} =
|
||||||
template withLock*(a: Lock, body: untyped) =
|
template withLock*(a: Lock, body: untyped) =
|
||||||
## Acquires the given lock, executes the statements in body and
|
## Acquires the given lock, executes the statements in body and
|
||||||
## releases the lock after the statements finish executing.
|
## releases the lock after the statements finish executing.
|
||||||
mixin acquire, release
|
|
||||||
acquire(a)
|
acquire(a)
|
||||||
{.locks: [a].}:
|
{.locks: [a].}:
|
||||||
try:
|
try:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue