|
3 | 3 | //! is (1 << (usize::BITS - 2) - 2) |
4 | 4 | //! |
5 | 5 | //! - [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) |
7 | 7 | //! - 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) |
10 | 11 | //! |
11 | 12 | //! - [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`) |
14 | 15 | //! - 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. |
16 | 18 | //! - 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. |
20 | 21 | //! |
21 | 22 | //! # Safety |
22 | 23 | //! |
@@ -139,7 +140,7 @@ use std::task::{Context, Poll, Waker}; |
139 | 140 | use std::thread; |
140 | 141 | use std::time::{Duration, Instant}; |
141 | 142 |
|
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. |
143 | 144 | /// |
144 | 145 | /// # Limitation |
145 | 146 | /// |
|
0 commit comments