Skip to content

Commit 4865079

Browse files
committed
tweak verbiage of try_join/join fairness examples, tweaks to formatting/import organization
1 parent bc38c87 commit 4865079

File tree

3 files changed

+12
-19
lines changed

3 files changed

+12
-19
lines changed

tokio/src/macros/join.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ macro_rules! doc {
3232
///
3333
/// [`tokio::spawn`]: crate::spawn
3434
///
35-
/// # Fairness
35+
/// # Poll Ordering
3636
///
3737
/// By default, `join!`'s generated future rotates which contained
3838
/// future is polled first whenever it is woken.
@@ -44,12 +44,11 @@ macro_rules! doc {
4444
/// You may want this if your futures may interact in a way where known polling order is significant.
4545
///
4646
/// But there is an important caveat to this mode. It becomes your responsibility
47-
/// to ensure that the polling order of your futures is fair. If for example you
48-
/// are joining a stream and a shutdown future, and the stream has a
49-
/// huge volume of messages that takes a long time to finish processing per poll, you should
47+
/// to ensure that the polling order of your futures is reasonable. If for example you
48+
/// are joining a long-running server future with a shutdown future, and you want to make
49+
/// sure that no new requests are dispatched following a shutdown, you should
5050
/// place the shutdown future earlier in the `join!` list to ensure that it is
51-
/// always polled, and will not be delayed due to the stream future taking a long time to return
52-
/// `Poll::Pending`.
51+
/// always polled first.
5352
///
5453
/// # Examples
5554
///
@@ -225,8 +224,8 @@ doc! {macro_rules! join {
225224
() => { async {}.await }
226225
}}
227226

228-
#[derive(Default, Debug)]
229227
/// Rotates by one every [`Self::num_skip`] call up to COUNT - 1.
228+
#[derive(Default, Debug)]
230229
pub struct Rotator<const COUNT: u32> {
231230
next: u32,
232231
}

tokio/src/macros/support.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,7 @@ cfg_macros! {
33

44
pub use std::future::poll_fn;
55

6-
// Used with `join!` and `try_join!`
7-
pub use crate::macros::join::Rotator;
8-
// Used with `join!` and `try_join!`
9-
pub use crate::macros::join::BiasedRotator;
6+
pub use crate::macros::join::{BiasedRotator, Rotator};
107

118
#[doc(hidden)]
129
pub fn thread_rng_n(n: u32) -> u32 {
@@ -28,8 +25,6 @@ cfg_macros! {
2825
Poll::Ready(())
2926
}
3027
}
31-
32-
3328
}
3429

3530
pub use std::future::{Future, IntoFuture};

tokio/src/macros/try_join.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ macro_rules! doc {
3030
///
3131
/// [`tokio::spawn`]: crate::spawn
3232
///
33-
/// # Fairness
33+
/// # Poll Ordering
3434
///
3535
/// By default, `try_join!`'s generated future rotates which
3636
/// contained future is polled first whenever it is woken.
@@ -42,12 +42,11 @@ macro_rules! doc {
4242
/// You may want this if your futures may interact in a way where known polling order is significant.
4343
///
4444
/// But there is an important caveat to this mode. It becomes your responsibility
45-
/// to ensure that the polling order of your futures is fair. If for example you
46-
/// are joining a stream and a shutdown future, and the stream has a
47-
/// huge volume of messages that takes a long time to finish processing per poll, you should
45+
/// to ensure that the polling order of your futures is reasonable. If for example you
46+
/// are joining a long-running server future with a shutdown future, and you want to make
47+
/// sure that no new requests are dispatched following a shutdown, you should
4848
/// place the shutdown future earlier in the `try_join!` list to ensure that it is
49-
/// always polled, and will not be delayed due to the stream future taking a long time to return
50-
/// `Poll::Pending`.
49+
/// always polled first.
5150
///
5251
/// # Examples
5352
///

0 commit comments

Comments
 (0)