Skip to content

Commit

Permalink
Add portable-atomic feature
Browse files Browse the repository at this point in the history
  • Loading branch information
agerasev committed Sep 27, 2024
1 parent f7e1cf1 commit fbaad4d
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 3 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ license.workspace = true

[features]
default = ["std"]
std = ["alloc", "portable-atomic/std"]
std = ["alloc", "portable-atomic?/std"]
alloc = []
bench = []
test_local = []

[dependencies]
crossbeam-utils = { version = "0.8", default-features = false }
portable-atomic = "1"
portable-atomic = { version = "1", default-features = false, optional = true }

[dev-dependencies]
once_mut = "0.1.0"
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Lock-free SPSC FIFO ring buffer with direct access to inner data.
+ Different types of buffers and underlying storages.
+ Can be used without `std` and even without `alloc` (using only statically-allocated memory).
+ Async and blocking versions (see [this section](#derived-crates)).
+ Uses the `portable-atomic` crate to allow usage on smaller systems without CAS operations.
+ Can optionally use the [`portable-atomic`](https://crates.io/crates/portable-atomic) crate to allow usage on smaller systems without CAS operations.

# Usage

Expand Down
1 change: 1 addition & 0 deletions scripts/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

cargo test && \
cargo test --features test_local && \
cargo test --features portable-atomic && \
cargo check --no-default-features --features alloc && \
cargo check --no-default-features && \
cd async && \
Expand Down
3 changes: 3 additions & 0 deletions src/rb/shared.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,15 @@ use crate::{
};
#[cfg(feature = "alloc")]
use alloc::{boxed::Box, sync::Arc};
#[cfg(not(feature = "portable-atomic"))]
use core::sync::atomic::{AtomicBool, AtomicUsize, Ordering};
use core::{
mem::{ManuallyDrop, MaybeUninit},
num::NonZeroUsize,
ptr,
};
use crossbeam_utils::CachePadded;
#[cfg(feature = "portable-atomic")]
use portable_atomic::{AtomicBool, AtomicUsize, Ordering};

/// Ring buffer that can be shared between threads.
Expand Down

0 comments on commit fbaad4d

Please sign in to comment.