Skip to content

Commit dd1ded3

Browse files
committed
fix: rid warnings that only appear on the release profile
1 parent c4d0a79 commit dd1ded3

File tree

2 files changed

+24
-9
lines changed

2 files changed

+24
-9
lines changed

crates/base/src/rt_worker/supervisor/strategy_per_request.rs

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
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;
25

36
use event_worker::events::ShutdownReason;
47
use log::error;
@@ -36,7 +39,9 @@ pub async fn supervise(args: Arguments, oneshot: bool) -> (ShutdownReason, i64)
3639
let (cpu_timer, mut cpu_alarms_rx) = cpu_timer.unzip();
3740
let (_, hard_limit_ms) = cpu_timer_param.limits();
3841

42+
#[cfg(debug_assertions)]
3943
let mut current_thread_id = Option::<ThreadId>::None;
44+
4045
let mut is_worker_entered = false;
4146
let mut cpu_usage_metrics_rx = cpu_usage_metrics_rx.unwrap();
4247
let mut cpu_usage_ms = 0i64;
@@ -68,14 +73,16 @@ pub async fn supervise(args: Arguments, oneshot: bool) -> (ShutdownReason, i64)
6873

6974
Some(metrics) = cpu_usage_metrics_rx.recv() => {
7075
match metrics {
71-
CPUUsageMetrics::Enter(thread_id) => {
76+
CPUUsageMetrics::Enter(_thread_id) => {
7277
// INVARIANT: Thread ID MUST equal with previously captured
7378
// Thread ID.
7479
#[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+
}
7784

78-
current_thread_id = Some(thread_id);
85+
assert!(!is_worker_entered);
7986
is_worker_entered = true;
8087

8188
if let Some(Err(err)) = cpu_timer.as_ref().map(|it| it.reset()) {

crates/base/src/rt_worker/supervisor/strategy_per_worker.rs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
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;
25

36
use event_worker::events::ShutdownReason;
47
use log::error;
@@ -32,7 +35,9 @@ pub async fn supervise(args: Arguments) -> (ShutdownReason, i64) {
3235
let (cpu_timer, mut cpu_alarms_rx) = cpu_timer.unzip();
3336
let (soft_limit_ms, hard_limit_ms) = cpu_timer_param.limits();
3437

38+
#[cfg(debug_assertions)]
3539
let mut current_thread_id = Option::<ThreadId>::None;
40+
3641
let mut is_worker_entered = false;
3742
let mut cpu_usage_metrics_rx = cpu_usage_metrics_rx.unwrap();
3843
let mut cpu_usage_ms = 0i64;
@@ -85,13 +90,16 @@ pub async fn supervise(args: Arguments) -> (ShutdownReason, i64) {
8590

8691
Some(metrics) = cpu_usage_metrics_rx.recv() => {
8792
match metrics {
88-
CPUUsageMetrics::Enter(thread_id) => {
93+
CPUUsageMetrics::Enter(_thread_id) => {
8994
// INVARIANT: Thread ID MUST equal with previously captured
9095
// Thread ID.
9196
#[cfg(debug_assertions)]
92-
assert!(current_thread_id.unwrap_or(thread_id) == thread_id);
97+
{
98+
assert!(current_thread_id.unwrap_or(_thread_id) == _thread_id);
99+
current_thread_id = Some(_thread_id);
100+
}
93101

94-
current_thread_id = Some(thread_id);
102+
assert!(!is_worker_entered);
95103
is_worker_entered = true;
96104

97105
if let Some(Err(err)) = cpu_timer.as_ref().map(|it| it.reset()) {

0 commit comments

Comments
 (0)