Skip to content

Add is_disconnected functions to mpsc and mpmc channels#153170

Merged
rust-bors[bot] merged 3 commits intorust-lang:mainfrom
LevitatingBusinessMan:is_disconnected
Mar 19, 2026
Merged

Add is_disconnected functions to mpsc and mpmc channels#153170
rust-bors[bot] merged 3 commits intorust-lang:mainfrom
LevitatingBusinessMan:is_disconnected

Conversation

@LevitatingBusinessMan
Copy link
Contributor

@LevitatingBusinessMan LevitatingBusinessMan commented Feb 27, 2026

Add is_disconnected() functions to the Sender and Receiver of both mpmc an mpsc channels.

std::sync::mpmc::Sender<T>::is_disconnected(&self) -> bool
std::sync::mpmc::Receiver<T>::is_disconnected(&self) -> bool

std::sync::mpsc::Sender<T>::is_disconnected(&self) -> bool
std::sync::mpsc::Receiver<T>::is_disconnected(&self) -> bool

The mpsc methods are locked behind the mpsc_is_disconnected feature gate, which has no tracking issue yet.

ACP: rust-lang/libs-team#748
Tracking issue: #153668

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Feb 27, 2026
@rustbot
Copy link
Collaborator

rustbot commented Feb 27, 2026

r? @Mark-Simulacrum

rustbot has assigned @Mark-Simulacrum.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: @ChrisDenton, libs
  • @ChrisDenton, libs expanded to 8 candidates
  • Random selection from Mark-Simulacrum, joboet

@LevitatingBusinessMan
Copy link
Contributor Author

LevitatingBusinessMan commented Feb 27, 2026

@rustbot label +S-waiting-on-ACP

@rust-log-analyzer

This comment has been minimized.

@rustbot rustbot added the S-waiting-on-ACP Status: PR has an ACP and is waiting for the ACP to complete. label Feb 27, 2026
Copy link
Contributor

@a1phyr a1phyr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that it the doc should mention that if is_disconnected returns false, it does not guaranty anything in the future (eg a send/recv just after might fail anything).

This footgun can cause race conditions, so it should be documented.

View changes since this review

@Mark-Simulacrum Mark-Simulacrum removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Feb 28, 2026
@LevitatingBusinessMan
Copy link
Contributor Author

LevitatingBusinessMan commented Feb 28, 2026

This footgun can cause race conditions, so it should be documented.

I added the following text to the documentation:

/// Note that a return value of `false` does not guarantee the channel will
/// remain connected. The channel may be disconnected immediately after this method
/// returns, so a subsequent [`Sender::send`] may still fail with [`SendError`].

and subsequent versions for Receiver.

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Feb 28, 2026
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Feb 28, 2026
@LevitatingBusinessMan
Copy link
Contributor Author

LevitatingBusinessMan commented Mar 10, 2026

@rustbot label +S-waiting-on-review -S-waiting-on-ACP

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-ACP Status: PR has an ACP and is waiting for the ACP to complete. labels Mar 10, 2026
@LevitatingBusinessMan
Copy link
Contributor Author

Currently I've put the methods for mpmc behind #![feature(mpmc_channel)]. Somebody should tell me if that's a good idea, or that both variants should be gated behind the same feature.

@Mark-Simulacrum
Copy link
Member

@bors r+ rollup

I think it seems reasonable either way but this setup seems fine for the feature gate.

@rust-bors
Copy link
Contributor

rust-bors bot commented Mar 19, 2026

📌 Commit ce2de64 has been approved by Mark-Simulacrum

It is now in the queue for this repository.

@rust-bors rust-bors bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Mar 19, 2026
Zalathar added a commit to Zalathar/rust that referenced this pull request Mar 19, 2026
…ted, r=Mark-Simulacrum

Add is_disconnected functions to mpsc and mpmc channels

Add `is_disconnected()` functions to the `Sender` and `Receiver` of both `mpmc` an `mpsc` channels.

```rust
std::sync::mpmc::Sender<T>::is_disconnected(&self) -> bool
std::sync::mpmc::Receiver<T>::is_disconnected(&self) -> bool

std::sync::mpsc::Sender<T>::is_disconnected(&self) -> bool
std::sync::mpsc::Receiver<T>::is_disconnected(&self) -> bool
```

The `mpsc` methods are locked behind the `mpsc_is_disconnected` feature gate, which has no tracking issue yet.

ACP: rust-lang/libs-team#748
Tracking issue: rust-lang#153668
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Mar 19, 2026
…ted, r=Mark-Simulacrum

Add is_disconnected functions to mpsc and mpmc channels

Add `is_disconnected()` functions to the `Sender` and `Receiver` of both `mpmc` an `mpsc` channels.

```rust
std::sync::mpmc::Sender<T>::is_disconnected(&self) -> bool
std::sync::mpmc::Receiver<T>::is_disconnected(&self) -> bool

std::sync::mpsc::Sender<T>::is_disconnected(&self) -> bool
std::sync::mpsc::Receiver<T>::is_disconnected(&self) -> bool
```

The `mpsc` methods are locked behind the `mpsc_is_disconnected` feature gate, which has no tracking issue yet.

ACP: rust-lang/libs-team#748
Tracking issue: rust-lang#153668
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Mar 19, 2026
…ted, r=Mark-Simulacrum

Add is_disconnected functions to mpsc and mpmc channels

Add `is_disconnected()` functions to the `Sender` and `Receiver` of both `mpmc` an `mpsc` channels.

```rust
std::sync::mpmc::Sender<T>::is_disconnected(&self) -> bool
std::sync::mpmc::Receiver<T>::is_disconnected(&self) -> bool

std::sync::mpsc::Sender<T>::is_disconnected(&self) -> bool
std::sync::mpsc::Receiver<T>::is_disconnected(&self) -> bool
```

The `mpsc` methods are locked behind the `mpsc_is_disconnected` feature gate, which has no tracking issue yet.

ACP: rust-lang/libs-team#748
Tracking issue: rust-lang#153668
rust-bors bot pushed a commit that referenced this pull request Mar 19, 2026
…uwer

Rollup of 12 pull requests

Successful merges:

 - #152870 (Do not enable split debuginfo for windows-gnu)
 - #153333 (Fix bootstrap rust build failure for vxworks)
 - #153681 (ci: add runners for vanilla LLVM 22)
 - #153824 (Add `Wake` diagnostic item for `alloc::task::Wake`)
 - #154077 (Optimize 128-bit integer formatting)
 - #154078 (`define_callbacks` tweaks)
 - #151905 (Split the `dec2flt::RawFloat` trait for easier reuse)
 - #153170 (Add is_disconnected functions to mpsc and mpmc channels)
 - #153804 (Derive Macro Eq: link to more detailed documentation)
 - #153974 (Point at return type when it is the source of the type expectation)
 - #154018 (simplify and remove `tests/ui/kindck` and related tests)
 - #154041 (bootstrap: Allow `--bless`ing changes to editor settings files)
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Mar 19, 2026
…ted, r=Mark-Simulacrum

Add is_disconnected functions to mpsc and mpmc channels

Add `is_disconnected()` functions to the `Sender` and `Receiver` of both `mpmc` an `mpsc` channels.

```rust
std::sync::mpmc::Sender<T>::is_disconnected(&self) -> bool
std::sync::mpmc::Receiver<T>::is_disconnected(&self) -> bool

std::sync::mpsc::Sender<T>::is_disconnected(&self) -> bool
std::sync::mpsc::Receiver<T>::is_disconnected(&self) -> bool
```

The `mpsc` methods are locked behind the `mpsc_is_disconnected` feature gate, which has no tracking issue yet.

ACP: rust-lang/libs-team#748
Tracking issue: rust-lang#153668
rust-bors bot pushed a commit that referenced this pull request Mar 19, 2026
…uwer

Rollup of 19 pull requests

Successful merges:

 - #152870 (Do not enable split debuginfo for windows-gnu)
 - #153333 (Fix bootstrap rust build failure for vxworks)
 - #153681 (ci: add runners for vanilla LLVM 22)
 - #153727 (When single impl can satisfy inference error, suggest type)
 - #153824 (Add `Wake` diagnostic item for `alloc::task::Wake`)
 - #154077 (Optimize 128-bit integer formatting)
 - #154078 (`define_callbacks` tweaks)
 - #151905 (Split the `dec2flt::RawFloat` trait for easier reuse)
 - #153170 (Add is_disconnected functions to mpsc and mpmc channels)
 - #153308 (Add hygiene annotations for tokens in `macro_rules!` bodies)
 - #153557 (fix inference variables leaking into HIR const literal lowering logic)
 - #153804 (Derive Macro Eq: link to more detailed documentation)
 - #153913 (Fix some suggestions of the `for-loops-over-fallibles` lint)
 - #153974 (Point at return type when it is the source of the type expectation)
 - #153987 (mGCA: Lower const generic args to infer when needed)
 - #154018 (simplify and remove `tests/ui/kindck` and related tests)
 - #154036 (borrowck/type_check: remove helper left-over from unsized locals)
 - #154038 (merge `regions-outlives-nominal-type-*` tests into one file)
 - #154041 (bootstrap: Allow `--bless`ing changes to editor settings files)
rust-bors bot pushed a commit that referenced this pull request Mar 19, 2026
…uwer

Rollup of 19 pull requests

Successful merges:

 - #152870 (Do not enable split debuginfo for windows-gnu)
 - #153333 (Fix bootstrap rust build failure for vxworks)
 - #153681 (ci: add runners for vanilla LLVM 22)
 - #153727 (When single impl can satisfy inference error, suggest type)
 - #153824 (Add `Wake` diagnostic item for `alloc::task::Wake`)
 - #154077 (Optimize 128-bit integer formatting)
 - #154078 (`define_callbacks` tweaks)
 - #151905 (Split the `dec2flt::RawFloat` trait for easier reuse)
 - #153170 (Add is_disconnected functions to mpsc and mpmc channels)
 - #153308 (Add hygiene annotations for tokens in `macro_rules!` bodies)
 - #153557 (fix inference variables leaking into HIR const literal lowering logic)
 - #153804 (Derive Macro Eq: link to more detailed documentation)
 - #153913 (Fix some suggestions of the `for-loops-over-fallibles` lint)
 - #153974 (Point at return type when it is the source of the type expectation)
 - #153987 (mGCA: Lower const generic args to infer when needed)
 - #154018 (simplify and remove `tests/ui/kindck` and related tests)
 - #154036 (borrowck/type_check: remove helper left-over from unsized locals)
 - #154038 (merge `regions-outlives-nominal-type-*` tests into one file)
 - #154041 (bootstrap: Allow `--bless`ing changes to editor settings files)
@rust-bors rust-bors bot merged commit 981f837 into rust-lang:main Mar 19, 2026
11 checks passed
@rustbot rustbot added this to the 1.96.0 milestone Mar 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-libs Relevant to the library team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants