async_ach-ring 0.1.0

Async Atomic Channel
Documentation
use async_ach_ring::Ring;
use core::future::Future;
use core::pin::Pin;
use core::task::Poll;
use futures_test::task;

#[test]
fn test() {
    static RING: Ring<usize, 2, 2, 2> = Ring::new();
    let mut cx = task::noop_context();

    let mut push1 = RING.push(1);
    assert!(Pin::new(&mut push1).poll(&mut cx).is_ready());
    assert!(Pin::new(&mut push1).poll(&mut cx).is_ready());
    let mut pop1 = RING.pop();
    assert_eq!(Pin::new(&mut pop1).poll(&mut cx), Poll::Ready(1));
    assert!(Pin::new(&mut pop1).poll(&mut cx).is_pending());

    let mut push2 = RING.push(2);
    assert!(Pin::new(&mut push2).poll(&mut cx).is_ready());
    let mut push3 = RING.push(3);
    assert!(Pin::new(&mut push3).poll(&mut cx).is_ready());
    let mut push4 = RING.push(4);
    assert!(Pin::new(&mut push4).poll(&mut cx).is_pending());
    assert_eq!(Pin::new(&mut pop1).poll(&mut cx), Poll::Ready(2));
    assert!(Pin::new(&mut push4).poll(&mut cx).is_ready());
}