async_fifo/
lib.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#![doc = include_str!("../README.md")]
#![no_std]

#[cfg(any(test, feature = "blocking", doc))]
extern crate std;

extern crate alloc;

use core::sync::atomic::AtomicPtr;
use core::sync::atomic::Ordering::{SeqCst, Relaxed};

/// Atomic and asynchronous slots
pub mod slot;

/// First-in, first-out MPMC channels
pub mod fifo;

#[cfg(any(feature = "blocking", doc))]
mod blocking;

fn try_xchg_ptr<T>(atomic_ptr: &AtomicPtr<T>, old: *mut T, new: *mut T) -> bool {
    atomic_ptr.compare_exchange(old, new, SeqCst, Relaxed).is_ok()
}