cancellation

This commit is contained in:
2026-02-04 03:13:39 -08:00
parent 156df9ae86
commit 08871a5782
10 changed files with 268 additions and 141 deletions

View File

@@ -10,6 +10,7 @@ use tokio::select;
use tokio::sync::OnceCell;
use tokio::time::{interval, timeout};
use tokio_serial::{SerialPort, SerialStream};
use tokio_util::sync::CancellationToken;
use tracing::{debug, debug_span, error, info, instrument, warn};
use crate::{
@@ -504,8 +505,8 @@ impl ChimemonSource for Prs10Monitor {
info: OnceCell::new(),
}
}
async fn run(mut self, chan: ChimemonSourceChannel) {
info!("PRS10 task starting");
async fn run(mut self, chan: ChimemonSourceChannel, cancel: CancellationToken) {
info!("PRS10 task started");
if let Err(e) = self.set_info().await {
error!("Error starting PRS10: {e:?}");
return;
@@ -522,6 +523,9 @@ impl ChimemonSource for Prs10Monitor {
loop {
let msg = select! {
_ = cancel.cancelled() => {
return;
},
_ = status_timer.tick() => {
self.status_poll().await
},