Struct abi_stable::external_types::crossbeam_channel::RSender [−][src]
#[repr(C)]pub struct RSender<T> { /* fields omitted */ }
channels
only.Expand description
The sender end of a channel, which can be either bounded or unbounded.
Example
use abi_stable::external_types::crossbeam_channel as mpmc;
let (tx, rx) = mpmc::bounded::<&'static str>(1024);
std::thread::spawn(move || {
for _ in 0..4 {
tx.send("Are we there yet.").unwrap();
}
});
assert_eq!(rx.recv().unwrap(), "Are we there yet.");
assert_eq!(rx.recv().unwrap(), "Are we there yet.");
assert_eq!(rx.recv().unwrap(), "Are we there yet.");
assert_eq!(rx.recv().unwrap(), "Are we there yet.");
assert!(rx.recv().is_err());
Implementations
Blocks until value
is either sent,or the the other end is disconnected.
If the channel queue is full,this will block to send value
.
If the channel is disconnected,this will return an error with value
.
Example
use abi_stable::external_types::crossbeam_channel as mpmc;
let (tx, rx) = mpmc::bounded::<u32>(3);
tx.send(1057).unwrap();
drop(rx);
assert!(tx.send(0).is_err());
Immediately sends value
,or returns with an error.
An error will be returned in these 2 conditions:
-
the channel is full.
-
the channel has been disconnected.
If the channel has a capacity of 0,it will only send value
if
the other end is calling recv
.
Example
use abi_stable::external_types::crossbeam_channel as mpmc;
let (tx, rx) = mpmc::bounded::<bool>(1);
tx.try_send(true).unwrap();
assert!(tx.try_send(true).unwrap_err().is_full());
drop(rx);
assert!(tx.try_send(false).unwrap_err().is_disconnected());
Blocks until a timeout to send value
.
An error will be returned in these 2 conditions:
-
the value could not be sent before the timeout.
-
the channel has been disconnected.
If the channel has a capacity of 0,it will only send value
if
the other end calls recv
before the timeout.
Example
use abi_stable::external_types::crossbeam_channel as mpmc;
use std::time::Duration;
let (tx, rx) = mpmc::bounded::<()>(1);
let timeout = Duration::from_millis(1);
tx.send_timeout((), timeout).unwrap();
assert!(tx.send_timeout((), timeout).unwrap_err().is_timeout());
drop(rx);
assert!(tx.send_timeout((), timeout).unwrap_err().is_disconnected());
Returns true if there are no values in the channel queue.
Example
use abi_stable::external_types::crossbeam_channel as mpmc;
let (tx, rx) = mpmc::bounded::<()>(1);
assert!(tx.is_empty());
tx.send(()).unwrap();
assert!(!tx.is_empty());
rx.recv().unwrap();
assert!(tx.is_empty());
Returns true if the channel queue is full.
This always returns true for channels constructed with bounded(0)
.
Example
use abi_stable::external_types::crossbeam_channel as mpmc;
let (tx, rx) = mpmc::bounded::<()>(2);
assert!(!tx.is_full());
tx.send(()).unwrap();
assert!(!tx.is_full());
tx.send(()).unwrap();
assert!(tx.is_full());
rx.recv().unwrap();
assert!(!tx.is_full());
Returns the amount of values in the channel queue.
Example
use abi_stable::external_types::crossbeam_channel as mpmc;
let (tx, rx) = mpmc::bounded::<()>(2);
assert_eq!(tx.len(), 0);
tx.send(()).unwrap();
assert_eq!(tx.len(), 1);
tx.send(()).unwrap();
assert_eq!(tx.len(), 2);
rx.recv().unwrap();
assert_eq!(tx.len(), 1);
Returns the amount of values the channel queue can hold.
This returns None if the channel is unbounded.
Example
use abi_stable::external_types::crossbeam_channel as mpmc;
{
let (tx, rx) = mpmc::bounded::<()>(2);
assert_eq!(tx.capacity(), Some(2));
}
{
let (tx, rx) = mpmc::unbounded::<()>();
assert_eq!(tx.capacity(), None);
}
Trait Implementations
type StaticEquivalent = _static_RSender<__GetStaticEquivalent<T>>
type IsNonZeroType = False
type IsNonZeroType = False
Whether this type has a single invalid bit-pattern. Read more
The layout of the type provided by implementors.
const
-equivalents of the associated types.
Auto Trait Implementations
impl<T> RefUnwindSafe for RSender<T> where
T: RefUnwindSafe,
impl<T> UnwindSafe for RSender<T> where
T: UnwindSafe + RefUnwindSafe,
Blanket Implementations
Mutably borrows from an owned value. Read more
type ROwned = T
type ROwned = T
The owned type, stored in RCow::Owned
type ForSelf = WithMetadata_<T, T>
type ForSelf = WithMetadata_<T, T>
This is always WithMetadata_<Self, Self>
Compares the address of self
with the address of other
. Read more
Emulates the pipeline operator, allowing method syntax in more places. Read more
The same as piped
except that the function takes &Self
Useful for functions that take &Self
instead of Self
. Read more
The same as piped
, except that the function takes &mut Self
.
Useful for functions that take &mut Self
instead of Self
. Read more
Mutates self using a closure taking self by mutable reference, passing it along the method chain. Read more
Observes the value of self, passing it along unmodified. Useful in long method chains. Read more
Performs a conversion with Into
.
using the turbofish .into_::<_>()
syntax. Read more
Performs a reference to reference conversion with AsRef
,
using the turbofish .as_ref_::<_>()
syntax. Read more
Performs a mutable reference to mutable reference conversion with AsMut
,
using the turbofish .as_mut_::<_>()
syntax. Read more
unsafe fn transmute_element<T>(
self
) -> <Self as CanTransmuteElement<T>>::TransmutedPtr where
Self: CanTransmuteElement<T>,
unsafe fn transmute_element<T>(
self
) -> <Self as CanTransmuteElement<T>>::TransmutedPtr where
Self: CanTransmuteElement<T>,
Transmutes the element type of this pointer.. Read more
type Type = T
type Type = T
This is always Self
.
Converts a value back to the original type.
Converts a mutable reference back to the original type.
alloc
only.Converts a box back to the original type.
Converts a value back to the original type.
Converts a reference back to the original type.
Converts a mutable reference back to the original type.
alloc
only.Converts a box back to the original type.
alloc
only.Converts an Arc back to the original type.
alloc
only.Converts an Rc back to the original type.