@@ -13,73 +13,6 @@ fn num_workers() {
13
13
assert_eq ! ( 2 , rt. metrics( ) . num_workers( ) ) ;
14
14
}
15
15
16
- #[ test]
17
- fn num_blocking_threads ( ) {
18
- let rt = current_thread ( ) ;
19
- assert_eq ! ( 0 , rt. metrics( ) . num_blocking_threads( ) ) ;
20
- let _ = rt. block_on ( rt. spawn_blocking ( move || { } ) ) ;
21
- assert_eq ! ( 1 , rt. metrics( ) . num_blocking_threads( ) ) ;
22
-
23
- let rt = threaded ( ) ;
24
- assert_eq ! ( 0 , rt. metrics( ) . num_blocking_threads( ) ) ;
25
- let _ = rt. block_on ( rt. spawn_blocking ( move || { } ) ) ;
26
- assert_eq ! ( 1 , rt. metrics( ) . num_blocking_threads( ) ) ;
27
- }
28
-
29
- #[ test]
30
- fn num_idle_blocking_threads ( ) {
31
- let rt = current_thread ( ) ;
32
- assert_eq ! ( 0 , rt. metrics( ) . num_idle_blocking_threads( ) ) ;
33
- let _ = rt. block_on ( rt. spawn_blocking ( move || { } ) ) ;
34
- rt. block_on ( async {
35
- time:: sleep ( Duration :: from_millis ( 5 ) ) . await ;
36
- } ) ;
37
-
38
- // We need to wait until the blocking thread has become idle. Usually 5ms is
39
- // enough for this to happen, but not always. When it isn't enough, sleep
40
- // for another second. We don't always wait for a whole second since we want
41
- // the test suite to finish quickly.
42
- //
43
- // Note that the timeout for idle threads to be killed is 10 seconds.
44
- if 0 == rt. metrics ( ) . num_idle_blocking_threads ( ) {
45
- rt. block_on ( async {
46
- time:: sleep ( Duration :: from_secs ( 1 ) ) . await ;
47
- } ) ;
48
- }
49
-
50
- assert_eq ! ( 1 , rt. metrics( ) . num_idle_blocking_threads( ) ) ;
51
- }
52
-
53
- #[ test]
54
- fn blocking_queue_depth ( ) {
55
- let rt = tokio:: runtime:: Builder :: new_current_thread ( )
56
- . enable_all ( )
57
- . max_blocking_threads ( 1 )
58
- . build ( )
59
- . unwrap ( ) ;
60
-
61
- assert_eq ! ( 0 , rt. metrics( ) . blocking_queue_depth( ) ) ;
62
-
63
- let ready = Arc :: new ( Mutex :: new ( ( ) ) ) ;
64
- let guard = ready. lock ( ) . unwrap ( ) ;
65
-
66
- let ready_cloned = ready. clone ( ) ;
67
- let wait_until_ready = move || {
68
- let _unused = ready_cloned. lock ( ) . unwrap ( ) ;
69
- } ;
70
-
71
- let h1 = rt. spawn_blocking ( wait_until_ready. clone ( ) ) ;
72
- let h2 = rt. spawn_blocking ( wait_until_ready) ;
73
- assert ! ( rt. metrics( ) . blocking_queue_depth( ) > 0 ) ;
74
-
75
- drop ( guard) ;
76
-
77
- let _ = rt. block_on ( h1) ;
78
- let _ = rt. block_on ( h2) ;
79
-
80
- assert_eq ! ( 0 , rt. metrics( ) . blocking_queue_depth( ) ) ;
81
- }
82
-
83
16
#[ test]
84
17
fn num_alive_tasks ( ) {
85
18
let rt = current_thread ( ) ;
0 commit comments