mirror of
https://github.com/element-hq/matrix-authentication-service.git
synced 2026-05-11 19:44:55 +00:00
Use a tokio interval instead of a sleep in the activity tracker
This commit is contained in:
@@ -185,6 +185,8 @@ impl ActivityTracker {
|
||||
// This guard on the shutdown token is to ensure that if this task crashes for
|
||||
// any reason, the server will shut down
|
||||
let _guard = cancellation_token.clone().drop_guard();
|
||||
let mut interval = tokio::time::interval(interval);
|
||||
interval.set_missed_tick_behavior(tokio::time::MissedTickBehavior::Skip);
|
||||
|
||||
loop {
|
||||
tokio::select! {
|
||||
@@ -202,7 +204,7 @@ impl ActivityTracker {
|
||||
}
|
||||
|
||||
|
||||
() = tokio::time::sleep(interval) => {
|
||||
_ = interval.tick() => {
|
||||
self.flush().await;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user