Skip to content
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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

AsyncSemaphore and AsyncPriorityQueue. #147

wants to merge 3 commits into from

Conversation

cheatfate
Copy link
Collaborator

No description provided.


if i > 0:
waiters.delete(0, i - 1)
# Workaround for callSoon() not worked correctly before
Copy link
Member

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:
Copy link
Member

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:
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants