fix: make sink::With send after inner sink returns ready #2976
+29
−9
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.
If I understand how
Sinkis supposed to work, a call tostart_sendhas to immediately succeed a call topoll_readythat returnsPoll::Ready(Ok(()). Any yield betweenpoll_readyandstart_sendinvalidates readiness of the sink because it could become unavailable during the intermediate polling. At least that's what seems "right" and how I read the documentation.Currently in
With, the future containing the next item is polled after the inner sink's initialPoll::Ready, which could mean that it becomes un-ready while polling for the item, then sent the value when it is unavailable.The PR changes the helper method to call
poll_readyon the inner sink, then immediatelystart_sendthe item. Unfortunately that means that the item has to be buffered in the intervening time, which leads to breaking changes in theDebugandCloneimplementations.The PR that introduces the current implementation seems to pretty plainly say that it's following the sink semantics, whereas before it was not. But before !1880 is more like what this PR is doing, so I could be way off. That would be fine too, since I'd appreciate having any of my misconceptions of
Sinkcorrected.