/// 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>>,
}
/// 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>>,
}
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>>>),
}
#[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()
&*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
}
// 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
upgrade: MyUpgrade<T>,
}
-pub enum Failure<T> {
+pub enum Failure<T:Send> {
Empty,
Disconnected,
Upgraded(Receiver<T>),
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>),
/// 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,
#[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
port_dropped: AtomicBool, // flag if the channel has been destroyed.
}
-pub enum Failure<T> {
+pub enum Failure<T:Send> {
Empty,
Disconnected,
Upgraded(Receiver<T>),
UpWoke(SignalToken),
}
-pub enum SelectionResult<T> {
+pub enum SelectionResult<T:Send> {
SelSuccess,
SelCanceled,
SelUpgraded(SignalToken, Receiver<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>),
}