Macro queuecheck::queuecheck_test [−][src]
macro_rules! queuecheck_test { ($pairs:expr, $producers:expr, $consumers:expr, $produce:expr, $consume:expr) => { ... }; }
Tests the supplied queue.
Example
The below tests the unbounded MPMC queue from the standard library by producing 100,000 items using two producer threads which are then consumed by one consumer thread.
use std::sync::mpsc::{self, Receiver, Sender}; let (producer, consumer) = mpsc::channel(); queuecheck_test!( // enqueue/dequeue operation pairs 100_000, // producer threads vec![producer.clone(), producer], // consumer threads vec![consumer], // produce operation |p: &Sender<String>, i: String| p.send(i).unwrap(), // consume operation |c: &Receiver<String>| c.try_recv().ok() );