Skip to content

Commit

Permalink
core/muxing: Drop Sync requirement for StreamMuxer on `StreamMuxe…
Browse files Browse the repository at this point in the history
…rBox` (#2775)

`StreamMuxerBox` is never shared across threads but owned by a single
connection. Restricting it to be `Sync` unnecessarily limits the design
space around the `StreamMuxer` trait and its implementations.
  • Loading branch information
thomaseizinger committed Jul 27, 2022
1 parent ce963df commit 56c492c
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
2 changes: 2 additions & 0 deletions core/CHANGELOG.md
Expand Up @@ -3,9 +3,11 @@
- Remove `StreamMuxer::poll_event` in favor of individual functions: `poll_inbound`, `poll_outbound`
and `poll_address_change`. Consequently, `StreamMuxerEvent` is also removed. See [PR 2724].
- Drop `Unpin` requirement from `SubstreamBox`. See [PR 2762] and [PR 2776].
- Drop `Sync` requirement on `StreamMuxer` for constructing `StreamMuxerBox`. See [PR 2775].

[PR 2724]: https://github.com/libp2p/rust-libp2p/pull/2724
[PR 2762]: https://github.com/libp2p/rust-libp2p/pull/2762
[PR 2775]: https://github.com/libp2p/rust-libp2p/pull/2775
[PR 2776]: https://github.com/libp2p/rust-libp2p/pull/2776

# 0.34.0
Expand Down
4 changes: 2 additions & 2 deletions core/src/muxing/boxed.rs
Expand Up @@ -10,7 +10,7 @@ use std::task::{Context, Poll};

/// Abstract `StreamMuxer`.
pub struct StreamMuxerBox {
inner: Box<dyn StreamMuxer<Substream = SubstreamBox, Error = io::Error> + Send + Sync>,
inner: Box<dyn StreamMuxer<Substream = SubstreamBox, Error = io::Error> + Send>,
}

/// Abstract type for asynchronous reading and writing.
Expand Down Expand Up @@ -70,7 +70,7 @@ impl StreamMuxerBox {
/// Turns a stream muxer into a `StreamMuxerBox`.
pub fn new<T>(muxer: T) -> StreamMuxerBox
where
T: StreamMuxer + Send + Sync + 'static,
T: StreamMuxer + Send + 'static,
T::Substream: Send + 'static,
T::Error: Send + Sync + 'static,
{
Expand Down
2 changes: 1 addition & 1 deletion core/src/transport/upgrade.rs
Expand Up @@ -299,7 +299,7 @@ impl<T> Multiplexed<T> {
T::Dial: Send + 'static,
T::ListenerUpgrade: Send + 'static,
T::Error: Send + Sync,
M: StreamMuxer + Send + Sync + 'static,
M: StreamMuxer + Send + 'static,
M::Substream: Send + 'static,
M::Error: Send + Sync + 'static,
{
Expand Down

0 comments on commit 56c492c

Please sign in to comment.