Skip to content

Commit 468978b

Browse files
committed
Use crossbeam_utils::BackOff as spin hint
1 parent 1c8bd57 commit 468978b

File tree

4 files changed

+5
-5
lines changed

4 files changed

+5
-5
lines changed

Diff for: Cargo.toml

+4-2
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@ homepage = "https://github.com/al8n/wg"
66
repository = "https://github.com/al8n/wg.git"
77
documentation = "https://docs.rs/wg/"
88
readme = "README.md"
9-
version = "0.9.0"
9+
version = "0.9.1"
1010
license = "MIT OR Apache-2.0"
1111
keywords = ["waitgroup", "async", "sync", "notify", "wake"]
1212
categories = ["asynchronous", "concurrency", "data-structures", "no-std"]
1313
edition = "2021"
1414

1515
[features]
1616
default = ["std", "parking_lot", "triomphe"]
17-
alloc = ["event-listener"]
17+
alloc = ["crossbeam-utils"]
1818
std = ["triomphe?/default", "event-listener?/default", "futures-core?/default"]
1919
triomphe = ["dep:triomphe"]
2020
parking_lot = ["dep:parking_lot"]
@@ -28,6 +28,8 @@ event-listener = { version = "5", optional = true, default-features = false, fea
2828
pin-project-lite = { version = "0.2", optional = true }
2929
futures-core = { version = "0.3", default-features = false, optional = true }
3030

31+
crossbeam-utils = { version = "0.8", optional = true, default-features = false }
32+
3133
[dev-dependencies]
3234
agnostic-lite = { version = "0.3", features = ["smol", "async-std", "tokio", "time"] }
3335
tokio = { version = "1", features = ["full"] }

Diff for: src/future.rs

-1
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,6 @@ pin_project_lite::pin_project! {
273273
/// A future returned by [`AsyncWaitGroup::wait()`].
274274
#[derive(Debug)]
275275
#[must_use = "futures do nothing unless you `.await` or poll them"]
276-
#[cfg_attr(docsrs, doc(cfg(feature = "tokio")))]
277276
pub struct WaitGroupFuture<'a> {
278277
inner: &'a AsyncWaitGroup,
279278
#[pin]

Diff for: src/no_std.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ impl WaitGroup {
160160
/// ```
161161
pub fn wait(&self) {
162162
while self.inner.counter.load(Ordering::SeqCst) != 0 {
163-
core::hint::spin_loop();
163+
crossbeam_utils::Backoff::new().spin();
164164
}
165165
}
166166
}

Diff for: src/sync.rs

-1
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,6 @@ impl WaitGroup {
162162
/// [`wait`]: struct.AsyncWaitGroup.html#method.wait
163163
pub fn add(&self, num: usize) -> Self {
164164
let mut ctr = self.inner.count.lock_me();
165-
166165
*ctr += num;
167166
Self {
168167
inner: self.inner.clone(),

0 commit comments

Comments
 (0)