Skip to content

Commit ddcb97b

Browse files
committed
bumpup version
1 parent 57a06d4 commit ddcb97b

File tree

4 files changed

+21
-68
lines changed

4 files changed

+21
-68
lines changed

Cargo.toml

+9-4
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ 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.1"
9+
version = "0.9.2"
1010
license = "MIT OR Apache-2.0"
1111
keywords = ["waitgroup", "async", "sync", "notify", "wake"]
1212
categories = ["asynchronous", "concurrency", "data-structures", "no-std"]
@@ -26,12 +26,12 @@ triomphe = { version = "0.1", optional = true, default-features = false }
2626
event-listener = { version = "5", optional = true, default-features = false, features = ["portable-atomic"] }
2727

2828
pin-project-lite = { version = "0.2", optional = true }
29-
futures-core = { version = "0.3", default-features = false, optional = true }
29+
futures-core = { version = "^0.3.31", default-features = false, optional = true }
3030

3131
crossbeam-utils = { version = "0.8", optional = true, default-features = false }
3232

3333
[dev-dependencies]
34-
agnostic-lite = { version = "0.3", features = ["smol", "async-std", "tokio", "time"] }
34+
agnostic-lite = { version = "^0.3.16", features = ["smol", "async-std", "tokio", "time"] }
3535
tokio = { version = "1", features = ["full"] }
3636
async-std = { version = "1", features = ["attributes"] }
3737
smol = "2"
@@ -43,9 +43,14 @@ rustdoc-args = ["--cfg", "docsrs"]
4343
[[test]]
4444
name = "future"
4545
path = "tests/future.rs"
46-
required-features = ["future"]
46+
required-features = ["tokio"]
4747

4848
[[test]]
4949
name = "sync"
5050
path = "tests/sync.rs"
5151

52+
[[example]]
53+
name = "future"
54+
path = "examples/future.rs"
55+
required-features = ["tokio"]
56+

README.md

+1-61
Original file line numberDiff line numberDiff line change
@@ -57,67 +57,7 @@ enbale `future` feature in your `Cargo.toml` and use `wg::AsyncWaitGroup`.
5757

5858
## Examples
5959

60-
### Sync
61-
62-
```rust
63-
use wg::WaitGroup;
64-
use std::sync::Arc;
65-
use std::sync::atomic::{AtomicUsize, Ordering};
66-
use std::time::Duration;
67-
use std::thread::{spawn, sleep};
68-
69-
fn main() {
70-
let wg = WaitGroup::new();
71-
let ctr = Arc::new(AtomicUsize::new(0));
72-
73-
for _ in 0..5 {
74-
let ctrx = ctr.clone();
75-
let t_wg = wg.add(1);
76-
spawn(move || {
77-
// mock some time consuming task
78-
sleep(Duration::from_millis(50));
79-
ctrx.fetch_add(1, Ordering::Relaxed);
80-
81-
// mock task is finished
82-
t_wg.done();
83-
});
84-
}
85-
86-
wg.wait();
87-
assert_eq!(ctr.load(Ordering::Relaxed), 5);
88-
}
89-
```
90-
91-
### Async
92-
93-
```rust
94-
use wg::AsyncWaitGroup;
95-
use std::sync::Arc;
96-
use std::sync::atomic::{AtomicUsize, Ordering};
97-
use tokio::{spawn, time::{sleep, Duration}};
98-
99-
#[tokio::main]
100-
async fn main() {
101-
let wg = AsyncWaitGroup::new();
102-
let ctr = Arc::new(AtomicUsize::new(0));
103-
104-
for _ in 0..5 {
105-
let ctrx = ctr.clone();
106-
let t_wg = wg.add(1);
107-
spawn(async move {
108-
// mock some time consuming task
109-
sleep(Duration::from_millis(50)).await;
110-
ctrx.fetch_add(1, Ordering::Relaxed);
111-
112-
// mock task is finished
113-
t_wg.done();
114-
});
115-
}
116-
117-
wg.wait().await;
118-
assert_eq!(ctr.load(Ordering::Relaxed), 5);
119-
}
120-
```
60+
Please see [examples](./examples) for details.
12161

12262
## Acknowledgements
12363

src/future.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ struct AsyncInner {
2222
}
2323

2424
/// An AsyncWaitGroup waits for a collection of threads to finish.
25+
///
2526
/// The main thread calls [`add`] to set the number of
2627
/// thread to wait for. Then each of the tasks
2728
/// runs and calls Done when finished. At the same time,
@@ -280,7 +281,7 @@ pin_project_lite::pin_project! {
280281
}
281282
}
282283

283-
impl<'a> core::future::Future for WaitGroupFuture<'a> {
284+
impl core::future::Future for WaitGroupFuture<'_> {
284285
type Output = ();
285286

286287
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {

src/sync.rs

+9-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@ trait Mu {
77

88
#[cfg(feature = "parking_lot")]
99
impl<T: ?Sized> Mu for parking_lot::Mutex<T> {
10-
type Guard<'a> = parking_lot::MutexGuard<'a, T> where Self: 'a;
10+
type Guard<'a>
11+
= parking_lot::MutexGuard<'a, T>
12+
where
13+
Self: 'a;
1114

1215
fn lock_me(&self) -> Self::Guard<'_> {
1316
self.lock()
@@ -16,7 +19,10 @@ impl<T: ?Sized> Mu for parking_lot::Mutex<T> {
1619

1720
#[cfg(not(feature = "parking_lot"))]
1821
impl<T: ?Sized> Mu for std::sync::Mutex<T> {
19-
type Guard<'a> = std::sync::MutexGuard<'a, T> where Self: 'a;
22+
type Guard<'a>
23+
= std::sync::MutexGuard<'a, T>
24+
where
25+
Self: 'a;
2026

2127
fn lock_me(&self) -> Self::Guard<'_> {
2228
self.lock().unwrap()
@@ -38,6 +44,7 @@ struct Inner {
3844
}
3945

4046
/// A WaitGroup waits for a collection of threads to finish.
47+
///
4148
/// The main thread calls [`add`] to set the number of
4249
/// thread to wait for. Then each of the goroutines
4350
/// runs and calls Done when finished. At the same time,

0 commit comments

Comments
 (0)