pub enum Item<T> {
Immediate(T),
Scheduled(T, Instant),
}
Expand description
Represents queued item.
Variants§
Immediate(T)
Item queued to be received immediately.
Scheduled(T, Instant)
Item queued to be received at a specified instant.
Implementations§
Source§impl<T> Item<T>
impl<T> Item<T>
Sourcepub fn value(&self) -> &T
pub fn value(&self) -> &T
Returns reference to the item value.
Examples found in repository?
examples/simple.rs (line 16)
7fn main() {
8 let (tx, mut rx) = FutexQueue::<u32, 4>::new();
9 let now = Instant::now();
10
11 let thread = thread::spawn(move || loop {
12 let item = rx.recv();
13 println!(
14 "{} ms: Received: {}",
15 now.elapsed().as_millis(),
16 item.value()
17 );
18 });
19
20 tx.send(1).unwrap();
21 tx.send_scheduled(2, now + Duration::from_secs(1)).unwrap();
22 tx.send(3).unwrap();
23 tx.send_scheduled(4, now + Duration::from_secs(2)).unwrap();
24
25 thread.join().unwrap();
26}
Sourcepub fn into_value(self) -> T
pub fn into_value(self) -> T
Consumes item to unwrap the contained value.
Trait Implementations§
Source§impl<T> Ord for Item<T>
impl<T> Ord for Item<T>
Source§impl<T> PartialOrd for Item<T>
impl<T> PartialOrd for Item<T>
impl<T> Eq for Item<T>
Auto Trait Implementations§
impl<T> Freeze for Item<T>where
T: Freeze,
impl<T> RefUnwindSafe for Item<T>where
T: RefUnwindSafe,
impl<T> Send for Item<T>where
T: Send,
impl<T> Sync for Item<T>where
T: Sync,
impl<T> Unpin for Item<T>where
T: Unpin,
impl<T> UnwindSafe for Item<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more