Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,13 @@ std = ["alloc", "parking_lot"]
alloc = []
default = ["std"]
static = []
portable_atomic = []

[dependencies]
pin-project = "1"
parking_lot = { version = "0.12", optional = true, default-features = false }
portable-atomic = { version = "1.9.0", default-features = false, features = ["require-cas", "critical-section"] }
portable-atomic-util = { version = "0.2.4", default-features = false, features = ["alloc"] }

[dev-dependencies]
tokio = { version = "1.14.0", features = ["rt", "rt-multi-thread", "macros", "sync"] }
Expand Down
8 changes: 4 additions & 4 deletions src/loom.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,13 +205,13 @@ mod inner {
#![allow(dead_code)]
pub(crate) mod sync {
#[allow(unused_imports)]
pub use core::sync::*;
pub use portable_atomic as atomic;

#[cfg(feature = "alloc")]
#[cfg(all(feature = "alloc", not(feature = "portable_atomic")))]
pub use alloc::sync::*;
}

pub(crate) use core::sync::atomic;
pub(crate) use portable_atomic as atomic;

#[cfg(feature = "std")]
pub use std::thread;
Expand All @@ -221,7 +221,7 @@ mod inner {
pub(crate) fn spin_loop() {
// MSRV: std::hint::spin_loop() stabilized in 1.49.0
#[allow(deprecated)]
super::atomic::spin_loop_hint()
core::sync::atomic::spin_loop_hint(); // Apparently portable_atomic doesn't have spin_loop_hint
}
}

Expand Down
9 changes: 8 additions & 1 deletion src/mpsc/async_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,14 @@ use errors::*;
feature! {
#![feature = "alloc"]

use crate::{MAX_CAPACITY, loom::sync::Arc};
use crate::{MAX_CAPACITY};

#[cfg(not(feature = "portable_atomic"))]
use crate::loom::sync::Arc;

#[cfg(feature = "portable_atomic")]
use portable_atomic_util::Arc;

use alloc::boxed::Box;

/// Returns a new asynchronous multi-producer, single consumer (MPSC)
Expand Down
8 changes: 7 additions & 1 deletion src/recycling.rs
Original file line number Diff line number Diff line change
Expand Up @@ -390,10 +390,16 @@ feature! {
use alloc::{
collections::{VecDeque, BinaryHeap},
string::String,
sync::Arc,
vec::Vec,
};

#[cfg(all(feature = "alloc", not(feature = "portable_atomic")))]
use alloc::sync::Arc;

#[cfg(all(feature = "alloc", feature = "portable_atomic"))]
use portable_atomic_util::Arc;


impl<T, R> Recycle<T> for Arc<R>
where
R: Recycle<T>,
Expand Down