|
1 |
| -use std::{future::pending, sync::atomic::Ordering, thread::ThreadId, time::Duration}; |
| 1 | +use std::{future::pending, sync::atomic::Ordering, time::Duration}; |
| 2 | + |
| 3 | +#[cfg(debug_assertions)] |
| 4 | +use std::thread::ThreadId; |
2 | 5 |
|
3 | 6 | use event_worker::events::ShutdownReason;
|
4 | 7 | use log::error;
|
@@ -36,7 +39,9 @@ pub async fn supervise(args: Arguments, oneshot: bool) -> (ShutdownReason, i64)
|
36 | 39 | let (cpu_timer, mut cpu_alarms_rx) = cpu_timer.unzip();
|
37 | 40 | let (_, hard_limit_ms) = cpu_timer_param.limits();
|
38 | 41 |
|
| 42 | + #[cfg(debug_assertions)] |
39 | 43 | let mut current_thread_id = Option::<ThreadId>::None;
|
| 44 | + |
40 | 45 | let mut is_worker_entered = false;
|
41 | 46 | let mut cpu_usage_metrics_rx = cpu_usage_metrics_rx.unwrap();
|
42 | 47 | let mut cpu_usage_ms = 0i64;
|
@@ -68,14 +73,16 @@ pub async fn supervise(args: Arguments, oneshot: bool) -> (ShutdownReason, i64)
|
68 | 73 |
|
69 | 74 | Some(metrics) = cpu_usage_metrics_rx.recv() => {
|
70 | 75 | match metrics {
|
71 |
| - CPUUsageMetrics::Enter(thread_id) => { |
| 76 | + CPUUsageMetrics::Enter(_thread_id) => { |
72 | 77 | // INVARIANT: Thread ID MUST equal with previously captured
|
73 | 78 | // Thread ID.
|
74 | 79 | #[cfg(debug_assertions)]
|
75 |
| - assert!(current_thread_id.unwrap_or(thread_id) == thread_id); |
76 |
| - assert!(!is_worker_entered); |
| 80 | + { |
| 81 | + assert!(current_thread_id.unwrap_or(_thread_id) == _thread_id); |
| 82 | + current_thread_id = Some(_thread_id); |
| 83 | + } |
77 | 84 |
|
78 |
| - current_thread_id = Some(thread_id); |
| 85 | + assert!(!is_worker_entered); |
79 | 86 | is_worker_entered = true;
|
80 | 87 |
|
81 | 88 | if let Some(Err(err)) = cpu_timer.as_ref().map(|it| it.reset()) {
|
|
0 commit comments