Skip to content

Commit e42818b

Browse files
committed
doc: Refine doc in waitgroup
1 parent efd6d8e commit e42818b

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

src/waitgroup.rs

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,21 @@
33
//! is (1 << (usize::BITS - 2) - 2)
44
//!
55
//! - [WaitGroupInline]: Which embedded inline with its parent structure (with no dereference cost)
6-
//! - (Arc or other container should be used to share among threads).
6+
//! - (It requires its parent can be accessed by multi thread, for deep embedded scenario)
77
//! - Threshold is const
8-
//! - Requires manual ref count manager (add_many(), done_many()).
9-
//! - only one waiter thread is allowed.
8+
//! - Requires manual ref count manage, ([done()](WaitGroupInline::done) [done_many()](WaitGroupInline::done_many) is unsafe).
9+
//! - only one waiter thread is allowed. ([wait()](WaitGroupInline::wait),
10+
//! [wait_async()](WaitGroupInline::wait_async) is unsafe)
1011
//!
1112
//! - [WaitGroup]: which is a safe RAII guard API.
12-
//! - Its a box container, optional state inside may be shared between the threads of WaitGroup and its guards.
13-
//! - Only one waiter is allowed.
13+
//! - Its a referenced counted container, optional state inside may be shared between the threads of WaitGroup and its guards.
14+
//! - Only one waiter is allowed. (`WaitGroup` is `!Sync`)
1415
//! - Use [WaitGroup::add_guard()] to get [WaitGroupGuard].
15-
//! - `WaitGroupGuard` will increase ref, and drop will decrease ref and protentially wake the main thread.
16+
//! - [WaitGroupGuard] has `Clone` (Although `WaitGroup` can not `Clone`)
17+
//! - [WaitGroupGuard] drop will decrease ref and protentially wake the main thread.
1618
//! - Can change threshold at any time.
17-
//! - **NOTE**:
18-
//! threshold is carried inside generated [WaitGroupGuard] to minimize the cost of atomic ops.
19-
//! When changing threshold to larger value, wait() might not wake up as soon as new threshold reached.
19+
//! - **NOTE**: threshold is carried inside generated [WaitGroupGuard] to minimize the cost of atomic ops.
20+
//! When changing threshold to larger value, wait() might not wake up as soon as new threshold reached.
2021
//!
2122
//! # Safety
2223
//!
@@ -139,7 +140,7 @@ use std::task::{Context, Poll, Waker};
139140
use std::thread;
140141
use std::time::{Duration, Instant};
141142

142-
/// An unsafe version WaitGroup which does not allocate, must embedded in a parent Arc structure.
143+
/// An unsafe version WaitGroup which does not allocate, and not dereference cost, must embedded in a shared parent structure.
143144
///
144145
/// # Limitation
145146
///

0 commit comments

Comments
 (0)