File tree 3 files changed +13
-2
lines changed
3 files changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -8,7 +8,10 @@ impl Handle {
8
8
}
9
9
10
10
pub ( crate ) fn num_blocking_threads ( & self ) -> usize {
11
- self . blocking_spawner . num_threads ( )
11
+ // workers are currently spawned using spawn_blocking
12
+ self . blocking_spawner
13
+ . num_threads ( )
14
+ . saturating_sub ( self . num_workers ( ) )
12
15
}
13
16
14
17
pub ( crate ) fn num_idle_blocking_threads ( & self ) -> usize {
Original file line number Diff line number Diff line change @@ -8,7 +8,10 @@ impl Handle {
8
8
}
9
9
10
10
pub ( crate ) fn num_blocking_threads ( & self ) -> usize {
11
- self . blocking_spawner . num_threads ( )
11
+ // workers are currently spawned using spawn_blocking
12
+ self . blocking_spawner
13
+ . num_threads ( )
14
+ . saturating_sub ( self . num_workers ( ) )
12
15
}
13
16
14
17
pub ( crate ) fn num_idle_blocking_threads ( & self ) -> usize {
Original file line number Diff line number Diff line change @@ -31,6 +31,11 @@ fn num_blocking_threads() {
31
31
assert_eq ! ( 0 , rt. metrics( ) . num_blocking_threads( ) ) ;
32
32
let _ = rt. block_on ( rt. spawn_blocking ( move || { } ) ) ;
33
33
assert_eq ! ( 1 , rt. metrics( ) . num_blocking_threads( ) ) ;
34
+
35
+ let rt = threaded ( ) ;
36
+ assert_eq ! ( 0 , rt. metrics( ) . num_blocking_threads( ) ) ;
37
+ let _ = rt. block_on ( rt. spawn_blocking ( move || { } ) ) ;
38
+ assert_eq ! ( 1 , rt. metrics( ) . num_blocking_threads( ) ) ;
34
39
}
35
40
36
41
#[ test]
You can’t perform that action at this time.
0 commit comments