Skip to content

Commit ecfce3a

Browse files
committed
Use guaranteed delta history for changes in current pool size
1 parent 55664f1 commit ecfce3a

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/task/blocking.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -100,12 +100,12 @@ fn create_blocking_thread() {
100100
.spawn(move || {
101101
let wait_limit = Duration::from_millis(1000 + rand_sleep_ms);
102102

103-
CURRENT_POOL_SIZE.fetch_add(1, Ordering::Relaxed);
103+
CURRENT_POOL_SIZE.fetch_add(1, Ordering::SeqCst);
104104
while let Ok(task) = POOL.receiver.recv_timeout(wait_limit) {
105105
abort_on_panic(|| task.run());
106106
calculate_dispatch_frequency();
107107
}
108-
CURRENT_POOL_SIZE.fetch_sub(1, Ordering::Relaxed);
108+
CURRENT_POOL_SIZE.fetch_sub(1, Ordering::SeqCst);
109109
})
110110
.expect("cannot start a dynamic thread driving blocking tasks");
111111
}
@@ -123,7 +123,7 @@ fn schedule(t: async_task::Task<()>) {
123123
// expected pool size is above the MAX_THREADS (which is a
124124
// case won't happen)
125125
let pool_size = EXPECTED_POOL_SIZE.load(Ordering::Relaxed);
126-
let current_pool_size = CURRENT_POOL_SIZE.load(Ordering::Relaxed);
126+
let current_pool_size = CURRENT_POOL_SIZE.load(Ordering::SeqCst);
127127
let reward = (AVR_FREQUENCY.load(Ordering::Relaxed) as f64 / 2.0_f64) as u64;
128128

129129
if pool_size > current_pool_size && pool_size <= MAX_THREADS {

0 commit comments

Comments
 (0)