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

Problem: hard to test cooperative execution #14

Closed
wants to merge 1 commit into from

Conversation

yrashk
Copy link
Contributor

@yrashk yrashk commented Feb 12, 2021

This is because it relies on a scheduler outside of our domain
(JavaScript)

Solution: allow to run a callback after the queue is exhausted

This changes single_threaded::run_cooperatively type signature a bit,
adding an extra parameter.

The testing is still not perfect as we can't really ensure the callback
was called, but if it was, then we can run the assertions.

This can be alternatively done by something like join_all for all
futures representing tasks scheduled and spawning another task to do
something after they've been joined, but it seems at the time that
adding this callback has lower impact / easier ergonomics (but, of
course, it's less "pure" if you may)

This is because it relies on a scheduler outside of our domain
(JavaScript)

Solution: allow to run a callback after the queue is exhausted

This changes `single_threaded::run_cooperatively` type signature a bit,
adding an extra parameter.

The testing is still not perfect as we can't really ensure the callback
was called, but if it *was*, then we can run the assertions.

This can be alternatively done by something like `join_all` for all
futures representing tasks scheduled and spawning another task to do
something after they've been joined, but it seems at the time that
adding this callback has lower impact / easier ergonomics (but, of
course, it's less "pure" if you may)
@yrashk yrashk changed the title Problem: hard to test run_cooperative execution Problem: hard to test cooperative execution Feb 12, 2021
@yrashk
Copy link
Contributor Author

yrashk commented Feb 14, 2021

Obsoleted by #16

@yrashk yrashk closed this Feb 14, 2021
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.

None yet

1 participant