@@ -24,18 +24,15 @@ pub struct Sender<T> {
24
24
inner : mpmc:: Sender < T > ,
25
25
}
26
26
27
- /// The sending end of the channel can be sent between threads, as long as it is not used to
28
- /// receive non-sendable things.
27
+ /// SAFETY: Since the only methods in which synchronization must occur take full ownership of the
28
+ /// [`Sender`], it is perfectly safe to share a &[`Sender`] between threads (as it is effectively
29
+ /// useless without full ownership).
29
30
#[ unstable( feature = "oneshot_channel" , issue = "143674" ) ]
30
- unsafe impl < T : Send > Send for Sender < T > { }
31
-
32
- /// FIXME: Try to boil down <https://github.com/rust-lang/rust/pull/111087> into a doc comment.
33
- #[ unstable( feature = "oneshot_channel" , issue = "143674" ) ]
34
- unsafe impl < T : Send > Sync for Sender < T > { }
31
+ unsafe impl < T > Sync for Sender < T > { }
35
32
36
33
impl < T > Sender < T > {
37
34
/// Attempts to send a value through this channel. This can only fail if the corresponding
38
- /// `Receiver<T>` has been dropped.
35
+ /// [ `Receiver<T>`] has been dropped.
39
36
///
40
37
/// This method is non-blocking (wait-free).
41
38
#[ unstable( feature = "oneshot_channel" , issue = "143674" ) ]
@@ -62,19 +59,16 @@ pub struct Receiver<T> {
62
59
inner : mpmc:: Receiver < T > ,
63
60
}
64
61
65
- /// The receiving end of the channel can be sent between threads, as long as it is not used to
66
- /// receive non-sendable things.
67
- #[ unstable( feature = "oneshot_channel" , issue = "143674" ) ]
68
- unsafe impl < T : Send > Send for Receiver < T > { }
69
-
70
- /// FIXME: Why is `mpsc::Receiver` !Sync but `mpmc::Receiver` is? Write this in a doc comment.
62
+ /// SAFETY: Since the only methods in which synchronization must occur take full ownership of the
63
+ /// [`Receiver`], it is perfectly safe to share a &[`Receiver`] between threads (as it is unable to
64
+ /// receive any values without full ownership).
71
65
#[ unstable( feature = "oneshot_channel" , issue = "143674" ) ]
72
- impl < T > ! Sync for Receiver < T > { }
66
+ unsafe impl < T > Sync for Receiver < T > { }
73
67
74
68
impl < T > Receiver < T > {
75
69
/// Receives the value from the sending end, blocking the calling thread until it gets it.
76
70
///
77
- /// Can only fail if the corresponding `Sender<T>` has been dropped.
71
+ /// Can only fail if the corresponding [ `Sender<T>`] has been dropped.
78
72
#[ unstable( feature = "oneshot_channel" , issue = "143674" ) ]
79
73
pub fn recv ( self ) -> Result < T , RecvError > {
80
74
self . inner . recv ( )
0 commit comments