-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Support for !Send tasks #1216
Merged
Merged
Support for !Send tasks #1216
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
It looks like we're running all of the tasks on the local executor, regardless of the context they were spawned with. Maybe we should just have two scopes for simplicity / to avoid potential overhead when only one context is needed? Ex:
pool.scope()
andpool.local_scope()
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.
Ah wait. We're awaiting (and i assume that means polling) using the local executor only. Which might be fine? I'm not sure! Separate scopes would probably still be safest.
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.
Yep. The tasks run on the executor where they were spawned and are only awaited on the local executor. Doing it that way makes the code significantly cleaner because otherwise you have to basically duplicate every line because the executors have different types with no unifying trait.
I see that the tests I've added don't actually prove that this is running the tasks on the right threads. Let me add a test that demonstrates that. If you're still uncomfortable with it I can move to awaiting two groups of futures since I agree that is more obvious.
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.
I'm less worried about the parallelism (spawning the task with the proper executor is proof enough for me). I'm more worried about using the local executor to poll tasks that it didn't spawn. That seems a bit weird / might produce undefined behavior. I'm not sure how that's implemented (and even if the current implementation works, can we be sure that will always be the case?)
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.
That's a valid concern. Let me go read more in async-executor/std::future and see what the guarantees actually are.
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.
Ok, I am convinced this is a reasonable thing to do because of the way async-task is designed. When you spawn a future via their API they produce two structs, a Task and a Runnable. The Task, which is the only part we interact with directly, is used only to check for completion and retrieve the result, it doesn't participate in polling the underlying future at all. The Runnable, which is retained by the Executor/LocalExecutor is what actually polls the future when
try_tick
is called. So using the Task in a composite future that waits for results is exactly what it is intended for. Turning the crank on the executor to actually run the main futures is a completely separate process.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.
Alrighty I'm decently convinced at this point. Lets get this merged!