move assert into lock

This commit is contained in:
Dmitriy Ryajov 2023-09-14 18:23:37 -06:00
parent b2cb1fd371
commit 0fde28a994
No known key found for this signature in database
GPG Key ID: DA8C680CE7C657A4

View File

@ -44,11 +44,12 @@ proc release*(self: var Semaphore) {.inline.} =
if self.count <= 0:
self.count += 1
self.cond.signal()
self.lock.release()
doAssert not (self.count > self.size),
"Semaphore count is greather than size: " & $self.size & " count is: " & $self.count
self.lock.release()
template withSemaphore*(self: var Semaphore, body: untyped) =
self.acquire()
try: