Skip to content

Commit 25439f8

Browse files
committed
simplify features required
1 parent fa4e0a6 commit 25439f8

File tree

2 files changed

+8
-23
lines changed

2 files changed

+8
-23
lines changed

tokio/src/runtime/blocking/sharded_queue.rs

Lines changed: 7 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,7 @@
1616
use crate::loom::sync::{Condvar, Mutex};
1717

1818
use std::collections::VecDeque;
19-
#[cfg(not(all(
20-
not(loom),
21-
any(feature = "macros", all(feature = "sync", feature = "rt"))
22-
)))]
19+
#[cfg(loom)]
2320
use std::sync::atomic::Ordering::Relaxed;
2421
use std::sync::atomic::Ordering::{AcqRel, Acquire, Release};
2522
use std::sync::atomic::{AtomicBool, AtomicUsize};
@@ -61,11 +58,8 @@ pub(super) struct ShardedQueue {
6158
/// The shards - each with its own mutex-protected queue.
6259
shards: [Shard; NUM_SHARDS],
6360
/// Atomic counter for round-robin task distribution.
64-
/// Only used when randomness is not available (loom or missing features).
65-
#[cfg(not(all(
66-
not(loom),
67-
any(feature = "macros", all(feature = "sync", feature = "rt"))
68-
)))]
61+
/// Only used when randomness is not available (loom).
62+
#[cfg(loom)]
6963
push_index: AtomicUsize,
7064
/// Tracks the highest shard index that has ever been pushed to.
7165
/// This allows `pop()` to skip checking shards that have never had tasks,
@@ -97,10 +91,7 @@ impl ShardedQueue {
9791
pub(super) fn new() -> Self {
9892
ShardedQueue {
9993
shards: std::array::from_fn(|_| Shard::new()),
100-
#[cfg(not(all(
101-
not(loom),
102-
any(feature = "macros", all(feature = "sync", feature = "rt"))
103-
)))]
94+
#[cfg(loom)]
10495
push_index: AtomicUsize::new(0),
10596
max_shard_pushed: AtomicUsize::new(0),
10697
shutdown: AtomicBool::new(false),
@@ -111,20 +102,14 @@ impl ShardedQueue {
111102

112103
/// Select the next shard index for pushing a task -- when the RNG is
113104
/// available.
114-
#[cfg(all(
115-
not(loom),
116-
any(feature = "macros", all(feature = "sync", feature = "rt"))
117-
))]
105+
#[cfg(not(loom))]
118106
fn next_push_index(&self, num_shards: usize) -> usize {
119107
crate::runtime::context::thread_rng_n(num_shards as u32) as usize
120108
}
121109

122110
/// Select the next shard index for pushing a task -- when the RNG is not
123-
/// available.
124-
#[cfg(not(all(
125-
not(loom),
126-
any(feature = "macros", all(feature = "sync", feature = "rt"))
127-
)))]
111+
/// available (loom).
112+
#[cfg(loom)]
128113
fn next_push_index(&self, num_shards: usize) -> usize {
129114
self.push_index.fetch_add(1, Relaxed) & (num_shards - 1)
130115
}

tokio/src/runtime/context.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ tokio_thread_local! {
121121
}
122122
}
123123

124-
#[cfg(any(feature = "macros", all(feature = "sync", feature = "rt")))]
124+
#[cfg(any(feature = "macros", feature = "rt"))]
125125
pub(crate) fn thread_rng_n(n: u32) -> u32 {
126126
CONTEXT.with(|ctx| {
127127
let mut rng = ctx.rng.get().unwrap_or_else(FastRand::new);

0 commit comments

Comments
 (0)