sync: implement Sink and Stream for Signal#5491
Open
wojciech-graj wants to merge 1 commit intoembassy-rs:mainfrom
Open
sync: implement Sink and Stream for Signal#5491wojciech-graj wants to merge 1 commit intoembassy-rs:mainfrom
Sink and Stream for Signal#5491wojciech-graj wants to merge 1 commit intoembassy-rs:mainfrom
Conversation
a58cf55 to
1dafdad
Compare
The traits are implemented on a reference to Signal, because Signal is used for both sending and receiving, requires an immutable reference for both operations, and the Stream and Sink traits take a mutable reference.
1dafdad to
0d68873
Compare
Member
|
the impls feel a bit weird, since signal has space for only 1 element and loses the old value if it hasn't been picked up you typically don't use it to send streams of data like you would with a channel. What's the use case? |
Contributor
Author
|
My use-case is implementing some networking code in which I only care about the latest packet, and want to use a standard For prior art, see tokio's WatchStream (tokio doesn't have a |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The traits are implemented on a reference to Signal, because Signal
is used for both sending and receiving, requires an immutable
reference for both operations, and the Stream and Sink traits take a
mutable reference.