Skip to content

Commit

Permalink
Merge branch 'us-irs-use-portable-atomic-crate'
Browse files Browse the repository at this point in the history
  • Loading branch information
agerasev committed Sep 27, 2024
2 parents 1c16349 + fbaad4d commit 83d6c89
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 2 deletions.
3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,14 @@ license.workspace = true

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

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

[dev-dependencies]
once_mut = "0.1.0"
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +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)).
+ 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
5 changes: 4 additions & 1 deletion src/rb/shared.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,16 @@ 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,
sync::atomic::{AtomicBool, AtomicUsize, Ordering},
};
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 83d6c89

Please sign in to comment.