diff options
author | 2022-01-16 11:51:23 -0800 | |
---|---|---|
committer | 2022-01-17 11:32:13 -0800 | |
commit | bc9e208089a415f0400f88ba4a8bfd20d955e317 (patch) | |
tree | 115527275db30a7f385347b933bb2b1eeef22b78 /src/spsc.rs | |
parent | a68ce63fbed4e3f2da76687a8ed0b064167448b9 (diff) | |
download | heapless-bc9e208089a415f0400f88ba4a8bfd20d955e317.tar.gz heapless-bc9e208089a415f0400f88ba4a8bfd20d955e317.tar.zst heapless-bc9e208089a415f0400f88ba4a8bfd20d955e317.zip |
differentiate full vs CAS polyfill
Diffstat (limited to '')
-rw-r--r-- | src/spsc.rs | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/src/spsc.rs b/src/spsc.rs index 2c0a6b44..38990d56 100644 --- a/src/spsc.rs +++ b/src/spsc.rs @@ -2,8 +2,8 @@ //! //! Implementation based on <https://www.codeproject.com/Articles/43510/Lock-Free-Single-Producer-Single-Consumer-Circular> //! -//! NOTE: This module is not available on targets that do *not* support atomic loads, e.g. RISC-V -//! cores w/o the A (Atomic) extension +//! NOTE: This module is not available on targets that do *not* support atomic loads and are not +//! supported by [`atomic_polyfill`]. (e.g., MSP430). //! //! # Examples //! @@ -84,13 +84,12 @@ //! - The numbers reported correspond to the successful path (i.e. `Some` is returned by `dequeue` //! and `Ok` is returned by `enqueue`). -use core::{ - cell::UnsafeCell, - fmt, hash, - mem::MaybeUninit, - ptr, - sync::atomic::{AtomicUsize, Ordering}, -}; +use core::{cell::UnsafeCell, fmt, hash, mem::MaybeUninit, ptr}; + +#[cfg(full_atomic_polyfill)] +use atomic_polyfill::{AtomicUsize, Ordering}; +#[cfg(not(full_atomic_polyfill))] +use core::sync::atomic::{AtomicUsize, Ordering}; /// A statically allocated single producer single consumer queue with a capacity of `N - 1` elements /// |