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

Async task not waiting for event once fired #51

Open
nitely opened this issue May 12, 2024 · 0 comments
Open

Async task not waiting for event once fired #51

nitely opened this issue May 12, 2024 · 0 comments

Comments

@nitely
Copy link

nitely commented May 12, 2024

The use case is waiting for some event until some condition is met. If the condition is not met, it should go back to wait. In the following code the condition is never met (the while true simulates this), but the async proc does not wait again (or it waits but it's immediately awaken)

block:
    var event = newAsyncEv()

    proc testEvent(n: int, ev: AsyncEv) {.async.} =
      while true:
        await ev.wait()
        debugEcho n

    event.clear()
    asyncCheck testEvent(0, event)
    asyncCheck testEvent(1, event)
    event.fire()
    event.clear()
    waitFor sleepAsync(10_000)

Current output:

0
1
0
1
0
1
[so on]

Expected:

0
1
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

No branches or pull requests

1 participant