File tree 1 file changed +7
-2
lines changed
1 file changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -260,7 +260,7 @@ fn create_blocking_thread() {
260
260
let _ = thread:: Builder :: new ( )
261
261
. name ( "async-blocking-driver-dynamic" . to_string ( ) )
262
262
. spawn ( move || {
263
- let wait_limit = Duration :: from_millis ( 1000 + rand_sleep_ms) ;
263
+ let wait_limit = Duration :: from_millis ( 1000_u64 + rand_sleep_ms) ;
264
264
265
265
// Adjust the pool size counter before and after spawn
266
266
* POOL_SIZE . lock ( ) . unwrap ( ) += 1 ;
@@ -276,7 +276,12 @@ fn create_blocking_thread() {
276
276
// Also, some systems have it(like macOS), and some don't(Linux).
277
277
// This case expected not to happen.
278
278
// But when happened this shouldn't throw a panic.
279
- MAX_THREADS . store ( * POOL_SIZE . lock ( ) . unwrap ( ) - 1 , Ordering :: SeqCst ) ;
279
+ let guarded_count = POOL_SIZE
280
+ . lock ( )
281
+ . unwrap ( )
282
+ . checked_sub ( 1 )
283
+ . expect ( "shouldn't underflow" ) ;
284
+ MAX_THREADS . store ( guarded_count, Ordering :: SeqCst ) ;
280
285
}
281
286
_ => eprintln ! (
282
287
"cannot start a dynamic thread driving blocking tasks: {}" ,
You can’t perform that action at this time.
0 commit comments