-
Notifications
You must be signed in to change notification settings - Fork 38
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
Remove ReceiveFuture::cancel
in favor of cancellation-safety docs
#138
Merged
Merged
Changes from 3 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
d92bbb1
Remove `ReceiveFuture::cancel` in favor of cancellation-safety docs
thomaseizinger 5605939
Fix doc reference
thomaseizinger 5857f42
Use `now_or_never` instead of awaiting
thomaseizinger 222ae09
Point users to `FutureExt::now_or_never`
thomaseizinger 753ad12
Add one more test
thomaseizinger 1a3e3dc
Merge branch 'master' into remove-receive-future-cancel
thomaseizinger 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
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.
I think the race here would be:
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.
Therefore, this is better in most but not all cases than just dropping
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.
Sorry, I don't fully understand.
I think this test proves that, once you have a
ReceiveFuture
, it can complete in a single poll, even if it has never been polled yet. Isn't this enough?I guess we are not testing the case in which it is
Waiting
.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.
What do you think of other test I just added in 753ad12?
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 agree, but this is not the race which I was describing. I might be able to write a test tomorrow showing exactly what I mean, though not with now_or_never, but with manual polling emulating it.
I think the other test is also valuable, but doesn't quite test what I meant.
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 think it comes down to what kind of ordering we would like to guarantee when multiple actors are involved.
now_or_never
has equivalent ordering withDrop
and evencancel
if there is only one receiving actor.In this case, the second actor has now handled the message out of order.
I don't actually think this is much of a problem, on second thought, but we should mention how ordering interacts with multiple actors, just in case, although I do not expect multiple actors on the same address to be relying on external message ordering.
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 see. What is missing for me in the above case is to do something with
rx_a
after we have initially polled it. I think it is okay for things to behave weirdly if you have half-polled futures around that are not interacted with.Drop
therx_a
future before the first send, it doesn't have a message and thus no re-ordering takes placeDrop
it afterwards, the message gets re-inserted and re-ordering might take place. This is documented with this PR.now_or_never
), the message will be delivered to you and you can pass it to an actor.(3) is what we are doing in the
select
function now which I think is functionally equivalent to what we had withcancel
.I don't think we want to make any guarantees in regards to message ordering with our work-stealing scheduling. That would be kind of bizarre.
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.
Fair enough. There was a similar discussion in flume at some point, if I remember correctly, and we came to a similar decision.
Technically, the message will be delivered to you whether or not you poll it more than once. As soon as you poll it once it will be delivered to you if the sender is given an opportunity.
Agreed.
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.
Okay. I think this is ready to merge then, right?
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 think so, yes. Maybe as part of #121 we can mention the ordering