Skip to content

Add Sender::make_receiver and Receiver::make_sender - #188

Open
ChrisJr404 wants to merge 1 commit into
zesterer:masterfrom
ChrisJr404:make-receiver-sender
Open

ChrisJr404 wants to merge 1 commit into
zesterer:masterfrom
ChrisJr404:make-receiver-sender

Conversation

@ChrisJr404

Copy link
Copy Markdown

Closes #155.

Both Sender and Receiver already hold an Arc to the same shared state, so this adds Sender::make_receiver and Receiver::make_sender to recover one half of a channel from the other. Handy when you only keep one side around in a data structure and don't want to store the pair, along the lines of tokio's watch::Sender::subscribe.

They just bump the relevant count and clone the Arc, so they behave like cloning the corresponding half. I added a couple of smoke tests in tests/basic.rs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Please support creating a Receiver from a Sender and vice versa

1 participant