Auto merge of #126839 - obeis:mpmc, r=Amanieu · qinheping/verify-rust-std@90d63b1 (original) (raw)

5 files changed

lines changed

Original file line number Diff line number Diff line change
@@ -153,7 +153,7 @@
153 153 //! the [`io`], [`fs`], and [`net`] modules.
154 154 //!
155 155 //! The [`thread`] module contains Rust's threading abstractions. [`sync`]
156 -//! contains further primitive shared memory types, including [`atomic`] and
156 +//! contains further primitive shared memory types, including [`atomic`], [`mpmc`] and
157 157 //! [`mpsc`], which contains the channel types for message passing.
158 158 //!
159 159 //! # Use before and after `main()`
@@ -177,6 +177,7 @@
177 177 //! - after-main use of thread-locals, which also affects additional features:
178 178 //! - [`thread::current()`]
179 179 //! - [`thread::scope()`]
180 +//! - [`sync::mpmc`]
180 181 //! - [`sync::mpsc`]
181 182 //! - before-main stdio file descriptors are not guaranteed to be open on unix platforms
182 183 //!
@@ -202,6 +203,7 @@
202 203 //! [`atomic`]: sync::atomic
203 204 //! [`for`]: ../book/ch03-05-control-flow.html#looping-through-a-collection-with-for
204 205 //! [`str`]: prim@str
206 +//! [`mpmc`]: sync::mpmc
205 207 //! [`mpsc`]: sync::mpsc
206 208 //! [`std::cmp`]: cmp
207 209 //! [`std::slice`]: mod@slice
Original file line number Diff line number Diff line change
@@ -133,6 +133,11 @@
133 133 //! inter-thread synchronisation mechanism, at the cost of some
134 134 //! extra memory.
135 135 //!
136 +//! - [`mpmc`]: Multi-producer, multi-consumer queues, used for
137 +//! message-based communication. Can provide a lightweight
138 +//! inter-thread synchronisation mechanism, at the cost of some
139 +//! extra memory.
140 +//!
136 141 //! - [`Mutex`]: Mutual Exclusion mechanism, which ensures that at
137 142 //! most one thread at a time is able to access some data.
138 143 //!
@@ -153,6 +158,7 @@
153 158 //! [`Arc`]: crate::sync::Arc
154 159 //! [`Barrier`]: crate::sync::Barrier
155 160 //! [`Condvar`]: crate::sync::Condvar
161 +//! [`mpmc`]: crate::sync::mpmc
156 162 //! [`mpsc`]: crate::sync::mpsc
157 163 //! [`Mutex`]: crate::sync::Mutex
158 164 //! [`Once`]: crate::sync::Once
@@ -193,12 +199,13 @@ pub use self::rwlock::{MappedRwLockReadGuard, MappedRwLockWriteGuard};
193 199 #[stable(feature = "rust1", since = "1.0.0")]
194 200 pub use self::rwlock::{RwLock, RwLockReadGuard, RwLockWriteGuard};
195 201
202 +#[unstable(feature = "mpmc_channel", issue = "126840")]
203 +pub mod mpmc;
196 204 pub mod mpsc;
197 205
198 206 mod barrier;
199 207 mod condvar;
200 208 mod lazy_lock;
201 -mod mpmc;
202 209 mod mutex;
203 210 pub(crate) mod once;
204 211 mod once_lock;
Original file line number Diff line number Diff line change
@@ -7,6 +7,7 @@ use crate::{error, fmt};
7 7 ///
8 8 /// [`send_timeout`]: super::Sender::send_timeout
9 9 #[derive(PartialEq, Eq, Clone, Copy)]
10 +#[unstable(feature = "mpmc_channel", issue = "126840")]
10 11 pub enum SendTimeoutError<T> {
11 12 /// The message could not be sent because the channel is full and the operation timed out.
12 13 ///
@@ -18,12 +19,14 @@ pub enum SendTimeoutError {
18 19 Disconnected(T),
19 20 }
20 21
22 +#[unstable(feature = "mpmc_channel", issue = "126840")]
21 23 impl<T> fmt::Debug for SendTimeoutError<T> {
22 24 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
23 25 "SendTimeoutError(..)".fmt(f)
24 26 }
25 27 }
26 28
29 +#[unstable(feature = "mpmc_channel", issue = "126840")]
27 30 impl<T> fmt::Display for SendTimeoutError<T> {
28 31 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
29 32 match *self {
@@ -33,8 +36,10 @@ impl fmt::Display for SendTimeoutError {
33 36 }
34 37 }
35 38
39 +#[unstable(feature = "mpmc_channel", issue = "126840")]
36 40 impl<T> error::Error for SendTimeoutError<T> {}
37 41
42 +#[unstable(feature = "mpmc_channel", issue = "126840")]
38 43 impl<T> From<SendError<T>> for SendTimeoutError<T> {
39 44 fn from(err: SendError<T>) -> SendTimeoutError<T> {
40 45 match err {