channel: Document that send_timeout sends an available message even if the timeout has elapsed#1289
Open
teddytennant wants to merge 1 commit into
Open
Conversation
…f the timeout has elapsed
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What
Adds a sentence to the doc comments of
Sender::send_timeoutandSender::send_deadlinenoting that a non-full channel accepts the message even when the timeout/deadline has already elapsed, and adds a unit test covering that behavior.Why
Follow-up to #1280, which documented this for the receiver side (
recv_timeout/recv_deadline, originally noted in #1245). The sender side has the exact mirror behavior for the same reason: the flavorsendimplementations attempt the send before checking the deadline, so a non-full channel accepts a message even for a zero/elapsed timeout. Thesend_timeout/send_deadlinedocstrings didn't mention it, leaving the send/recv docs inconsistent. This mirrors the wording from the receiver side, adapted to sender terminology.Testing
Added
send_timeout_nonfull_expiredtocrossbeam-channel/tests/array.rs, which assertssend_timeout(1, Duration::from_millis(0))returnsOk(())on a non-fullbounded(1)channel (message accepted despite the zero timeout) followed byErr(SendTimeoutError::Timeout(2))on the now-full channel. It is deterministic: everything runs on one thread andstart_sendon a non-full array channel succeeds on the first attempt before any timeout check.cargo test -p crossbeam-channel --test array send_timeout— 2 passed (including the new test)cargo test --doc -p crossbeam-channel— 74 passed (docstrings still compile)