-
Notifications
You must be signed in to change notification settings - Fork 51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AsyncSemaphore and AsyncPriorityQueue. #147
base: master
Are you sure you want to change the base?
Conversation
|
||
if i > 0: | ||
waiters.delete(0, i - 1) | ||
# Workaround for callSoon() not worked correctly before |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
callSoon
calls getThreadDispatcher
, why should this be needed here?
|
||
proc release*(asem: AsyncSemaphore) = | ||
## Release a semaphore, incrementing internal counter by one. | ||
if asem.counter >= asem.maxcounter: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
doAssert
?
## If the internal counter is larger than zero on entry, decrement it by one | ||
## and return immediately. If its zero on entry, block and wait until some | ||
## other task has called ``release()`` to make it larger than 0. | ||
while asem.counter <= 0: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the loop should not be needed here - there will be exactly one queue item per count below zero so they should line up perfectly
No description provided.