Skip to content

Commit ecfacfe

Browse files
foriequal0mergify[bot]
authored andcommitted
Remove derive(Clone) for TimerLoop
Clone can accidentially lead to someone sharing strong ref to scheduler
1 parent 4243be0 commit ecfacfe

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

util/timer/src/timer.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ pub trait TimeoutHandler: Send + Sync {
3434
fn on_timeout(&self, _token: TimerToken);
3535
}
3636

37-
#[derive(Clone)]
3837
pub struct TimerLoop {
39-
timer_id_nonce: Arc<AtomicUsize>,
38+
timer_id_nonce: AtomicUsize,
39+
4040
scheduler: Arc<Scheduler>,
4141
}
4242

@@ -57,7 +57,8 @@ impl TimerLoop {
5757
}
5858

5959
TimerLoop {
60-
timer_id_nonce: Arc::new(AtomicUsize::new(0)),
60+
timer_id_nonce: AtomicUsize::new(0),
61+
6162
scheduler,
6263
}
6364
}

0 commit comments

Comments
 (0)