@@ -60,7 +60,12 @@ impl Idle {
60
60
( idle, synced)
61
61
}
62
62
63
+ pub ( super ) fn needs_searching ( & self ) -> bool {
64
+ self . needs_searching . load ( Acquire )
65
+ }
66
+
63
67
pub ( super ) fn num_idle ( & self , synced : & Synced ) -> usize {
68
+ #[ cfg( not( loom) ) ]
64
69
debug_assert_eq ! ( synced. available_cores. len( ) , self . num_idle. load( Acquire ) ) ;
65
70
synced. available_cores . len ( )
66
71
}
@@ -131,13 +136,7 @@ impl Idle {
131
136
}
132
137
133
138
// We need to establish a stronger barrier than with `notify_local`
134
- if self
135
- . num_searching
136
- . compare_exchange ( 0 , 1 , AcqRel , Acquire )
137
- . is_err ( )
138
- {
139
- return ;
140
- }
139
+ self . num_searching . fetch_add ( 1 , AcqRel ) ;
141
140
142
141
self . notify_synced ( synced, shared) ;
143
142
}
@@ -158,6 +157,7 @@ impl Idle {
158
157
synced. assigned_cores [ worker] = Some ( core) ;
159
158
160
159
let num_idle = synced. idle . available_cores . len ( ) ;
160
+ #[ cfg( not( loom) ) ]
161
161
debug_assert_eq ! ( num_idle, self . num_idle. load( Acquire ) - 1 ) ;
162
162
163
163
// Update the number of sleeping workers
@@ -221,6 +221,7 @@ impl Idle {
221
221
let num_idle = synced. idle . available_cores . len ( ) ;
222
222
self . num_idle . store ( num_idle, Release ) ;
223
223
} else {
224
+ #[ cfg( not( loom) ) ]
224
225
debug_assert_eq ! (
225
226
synced. idle. available_cores. len( ) ,
226
227
self . num_idle. load( Acquire )
@@ -260,11 +261,11 @@ impl Idle {
260
261
// The core should not be searching at this point
261
262
debug_assert ! ( !core. is_searching) ;
262
263
263
- // Check that this isn't the final worker to go idle *and*
264
- // `needs_searching` is set.
265
- debug_assert ! ( !self . needs_searching. load( Acquire ) || num_active_workers( & synced. idle) > 1 ) ;
264
+ // Check that there are no pending tasks in the global queue
265
+ debug_assert ! ( synced. inject. is_empty( ) ) ;
266
266
267
267
let num_idle = synced. idle . available_cores . len ( ) ;
268
+ #[ cfg( not( loom) ) ]
268
269
debug_assert_eq ! ( num_idle, self . num_idle. load( Acquire ) ) ;
269
270
270
271
self . idle_map . set ( core. index ) ;
@@ -314,7 +315,7 @@ impl Idle {
314
315
}
315
316
}
316
317
317
- fn transition_worker_to_searching ( & self , core : & mut Core ) {
318
+ pub ( super ) fn transition_worker_to_searching ( & self , core : & mut Core ) {
318
319
core. is_searching = true ;
319
320
self . num_searching . fetch_add ( 1 , AcqRel ) ;
320
321
self . needs_searching . store ( false , Release ) ;
@@ -324,10 +325,7 @@ impl Idle {
324
325
///
325
326
/// Returns `true` if this is the final searching worker. The caller
326
327
/// **must** notify a new worker.
327
- pub ( super ) fn transition_worker_from_searching ( & self , core : & mut Core ) -> bool {
328
- debug_assert ! ( core. is_searching) ;
329
- core. is_searching = false ;
330
-
328
+ pub ( super ) fn transition_worker_from_searching ( & self ) -> bool {
331
329
let prev = self . num_searching . fetch_sub ( 1 , AcqRel ) ;
332
330
debug_assert ! ( prev > 0 ) ;
333
331
0 commit comments