Skip to content

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

@jhfrontz

Description

@jhfrontz

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 )

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-docsArea: Documentation for any part of the project, including the compiler, standard library, and toolsT-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions