Skip to content

AsyncSemaphore and AsyncPriorityQueue.#147

Open
cheatfate wants to merge 3 commits into
masterfrom
semaphore
Open

AsyncSemaphore and AsyncPriorityQueue.#147
cheatfate wants to merge 3 commits into
masterfrom
semaphore

Conversation

@cheatfate
Copy link
Copy Markdown
Collaborator

No description provided.

Comment thread chronos/asyncsync.nim

if i > 0:
waiters.delete(0, i - 1)
# Workaround for callSoon() not worked correctly before
Copy link
Copy Markdown
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?

Comment thread chronos/asyncsync.nim

proc release*(asem: AsyncSemaphore) =
## Release a semaphore, incrementing internal counter by one.
if asem.counter >= asem.maxcounter:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doAssert?

Comment thread chronos/asyncsync.nim
## 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
Copy Markdown
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