rust-lang / rust-lang/rust

Document guarantee: `sync_channel` `send()` ⇒ immediate `try_recv()` visibility.

Open
#146,135 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-docs T-libs
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

Location (URL)

Maybe https://doc.rust-lang.org/std/sync/mpsc/fn.sync_channel.html

Summary

Request: Make explicit in std::sync::mpsc::sync_channel docs that after Sender::send returns Ok(()), the message is enqueued such that an immediate Receiver::try_recv() on the same channel cannot return Empty.

Rationale: This is relied on for tests (where code calls send() and the test immediately calls try_recv() on the same channel to assert a message was produced). Implementation appears to already behave this way, but the guarantee isn’t stated. It's conceivable that in a different environment that an alternate implementation might be used that introduces the potential for messaging latency.

Ask: Treat this as a normative docs change.

(Reference: https://stackoverflow.com/questions/79753705/rust-mpscsync-channel-after-send-returns-can-try-recv-still-return-empty )

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked std::sync::mpsc::sync_channel documentation and inspect the surrounding Sender::send and Receiver::try_recv documentation. Update the normative text to state the requested post-send visibility guarantee, then check the surrounding standard-library documentation for consistency.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
documentation
Issue type
Documentation
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.