Added T:Send
bound to sync::mpsc::Receiver
and sync::mpsc::Sender
.
This was necessary to avoid specialized `Drop` impls for the two structs.
This commit is contained in:
parent
5fa4b4c4af
commit
0adab507bb
@ -342,7 +342,7 @@ mod spsc_queue;
|
||||
/// The receiving-half of Rust's channel type. This half can only be owned by
|
||||
/// one task
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub struct Receiver<T> {
|
||||
pub struct Receiver<T:Send> {
|
||||
inner: UnsafeCell<Flavor<T>>,
|
||||
}
|
||||
|
||||
@ -354,14 +354,14 @@ unsafe impl<T: Send> Send for Receiver<T> { }
|
||||
/// whenever `next` is called, waiting for a new message, and `None` will be
|
||||
/// returned when the corresponding channel has hung up.
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub struct Iter<'a, T:'a> {
|
||||
pub struct Iter<'a, T:Send+'a> {
|
||||
rx: &'a Receiver<T>
|
||||
}
|
||||
|
||||
/// The sending-half of Rust's asynchronous channel type. This half can only be
|
||||
/// owned by one task, but it can be cloned to send to other tasks.
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub struct Sender<T> {
|
||||
pub struct Sender<T:Send> {
|
||||
inner: UnsafeCell<Flavor<T>>,
|
||||
}
|
||||
|
||||
@ -433,7 +433,7 @@ pub enum TrySendError<T> {
|
||||
Disconnected(T),
|
||||
}
|
||||
|
||||
enum Flavor<T> {
|
||||
enum Flavor<T:Send> {
|
||||
Oneshot(Arc<UnsafeCell<oneshot::Packet<T>>>),
|
||||
Stream(Arc<UnsafeCell<stream::Packet<T>>>),
|
||||
Shared(Arc<UnsafeCell<shared::Packet<T>>>),
|
||||
@ -441,7 +441,7 @@ enum Flavor<T> {
|
||||
}
|
||||
|
||||
#[doc(hidden)]
|
||||
trait UnsafeFlavor<T> {
|
||||
trait UnsafeFlavor<T:Send> {
|
||||
fn inner_unsafe<'a>(&'a self) -> &'a UnsafeCell<Flavor<T>>;
|
||||
unsafe fn inner_mut<'a>(&'a self) -> &'a mut Flavor<T> {
|
||||
&mut *self.inner_unsafe().get()
|
||||
@ -450,12 +450,12 @@ trait UnsafeFlavor<T> {
|
||||
&*self.inner_unsafe().get()
|
||||
}
|
||||
}
|
||||
impl<T> UnsafeFlavor<T> for Sender<T> {
|
||||
impl<T:Send> UnsafeFlavor<T> for Sender<T> {
|
||||
fn inner_unsafe<'a>(&'a self) -> &'a UnsafeCell<Flavor<T>> {
|
||||
&self.inner
|
||||
}
|
||||
}
|
||||
impl<T> UnsafeFlavor<T> for Receiver<T> {
|
||||
impl<T:Send> UnsafeFlavor<T> for Receiver<T> {
|
||||
fn inner_unsafe<'a>(&'a self) -> &'a UnsafeCell<Flavor<T>> {
|
||||
&self.inner
|
||||
}
|
||||
|
@ -54,7 +54,7 @@ const DISCONNECTED: usize = 2; // channel is disconnected OR upgraded
|
||||
// moves *from* a pointer, ownership of the token is transferred to
|
||||
// whoever changed the state.
|
||||
|
||||
pub struct Packet<T> {
|
||||
pub struct Packet<T:Send> {
|
||||
// Internal state of the chan/port pair (stores the blocked task as well)
|
||||
state: AtomicUsize,
|
||||
// One-shot data slot location
|
||||
@ -64,7 +64,7 @@ pub struct Packet<T> {
|
||||
upgrade: MyUpgrade<T>,
|
||||
}
|
||||
|
||||
pub enum Failure<T> {
|
||||
pub enum Failure<T:Send> {
|
||||
Empty,
|
||||
Disconnected,
|
||||
Upgraded(Receiver<T>),
|
||||
@ -76,13 +76,13 @@ pub enum UpgradeResult {
|
||||
UpWoke(SignalToken),
|
||||
}
|
||||
|
||||
pub enum SelectionResult<T> {
|
||||
pub enum SelectionResult<T:Send> {
|
||||
SelCanceled,
|
||||
SelUpgraded(SignalToken, Receiver<T>),
|
||||
SelSuccess,
|
||||
}
|
||||
|
||||
enum MyUpgrade<T> {
|
||||
enum MyUpgrade<T:Send> {
|
||||
NothingSent,
|
||||
SendUsed,
|
||||
GoUp(Receiver<T>),
|
||||
|
@ -80,7 +80,7 @@ impl !marker::Send for Select {}
|
||||
/// A handle to a receiver which is currently a member of a `Select` set of
|
||||
/// receivers. This handle is used to keep the receiver in the set as well as
|
||||
/// interact with the underlying receiver.
|
||||
pub struct Handle<'rx, T:'rx> {
|
||||
pub struct Handle<'rx, T:Send+'rx> {
|
||||
/// The ID of this handle, used to compare against the return value of
|
||||
/// `Select::wait()`
|
||||
id: usize,
|
||||
|
@ -39,7 +39,7 @@ const MAX_STEALS: isize = 5;
|
||||
#[cfg(not(test))]
|
||||
const MAX_STEALS: isize = 1 << 20;
|
||||
|
||||
pub struct Packet<T> {
|
||||
pub struct Packet<T:Send> {
|
||||
queue: spsc::Queue<Message<T>>, // internal queue for all message
|
||||
|
||||
cnt: AtomicIsize, // How many items are on this channel
|
||||
@ -49,7 +49,7 @@ pub struct Packet<T> {
|
||||
port_dropped: AtomicBool, // flag if the channel has been destroyed.
|
||||
}
|
||||
|
||||
pub enum Failure<T> {
|
||||
pub enum Failure<T:Send> {
|
||||
Empty,
|
||||
Disconnected,
|
||||
Upgraded(Receiver<T>),
|
||||
@ -61,7 +61,7 @@ pub enum UpgradeResult {
|
||||
UpWoke(SignalToken),
|
||||
}
|
||||
|
||||
pub enum SelectionResult<T> {
|
||||
pub enum SelectionResult<T:Send> {
|
||||
SelSuccess,
|
||||
SelCanceled,
|
||||
SelUpgraded(SignalToken, Receiver<T>),
|
||||
@ -69,7 +69,7 @@ pub enum SelectionResult<T> {
|
||||
|
||||
// Any message could contain an "upgrade request" to a new shared port, so the
|
||||
// internal queue it's a queue of T, but rather Message<T>
|
||||
enum Message<T> {
|
||||
enum Message<T:Send> {
|
||||
Data(T),
|
||||
GoUp(Receiver<T>),
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ use thread;
|
||||
///
|
||||
/// The fields of this helper are all public, but they should not be used, this
|
||||
/// is for static initialization.
|
||||
pub struct Helper<M> {
|
||||
pub struct Helper<M:Send> {
|
||||
/// Internal lock which protects the remaining fields
|
||||
pub lock: StaticMutex,
|
||||
pub cond: StaticCondvar,
|
||||
|
Loading…
x
Reference in New Issue
Block a user