cancellation
This commit is contained in:
@@ -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
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user