rust-lang / rust-lang/rfcs

Add a WeakSender type

Open
#1,549 1 comment 8 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

T-libs
Dominant language
Markdown
Stars
6.6k
Forks
1.7k
Avg merge
16h 14m
Merged PRs (30d)
1

Description

The mpsc module should have a sender type that holds a weak reference to the channel. A WeakSender is to a Sender what a sync::Weak is to a sync::Arc. The channel will close if all Senders are dropped even if the Receiver is still alive.

The API for this could look similar to the Arc API. Just add a method Sender::downgrade(self) -> WeakSender<T>. This should be easy to implement given that Sender currently uses an Arc internally to hold it's reference to the channel.

Contributor guide

No contributing guide indexed for this repository

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

Begin by locating the mpsc implementation and its Sender's internal Arc, then compare the proposed API with sync::Arc and sync::Weak. Done means Sender::downgrade produces WeakSender, and the channel closes after all Sender values are dropped even while the Receiver remains alive; verify both behaviors with tests.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.