1616use crate :: loom:: sync:: { Condvar , Mutex } ;
1717
1818use std:: collections:: VecDeque ;
19- #[ cfg( not( all(
20- not( loom) ,
21- any( feature = "macros" , all( feature = "sync" , feature = "rt" ) )
22- ) ) ) ]
19+ #[ cfg( loom) ]
2320use std:: sync:: atomic:: Ordering :: Relaxed ;
2421use std:: sync:: atomic:: Ordering :: { AcqRel , Acquire , Release } ;
2522use 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 }
0 commit comments