rog-platform: refactor all related parts

This commit is contained in:
Luke D. Jones
2023-11-18 20:13:01 +13:00
parent fa043adc99
commit 1f696508e7
9 changed files with 343 additions and 263 deletions

View File

@@ -72,10 +72,15 @@ macro_rules! task_watch_item {
tokio::spawn(async move {
let mut buffer = [0; 32];
watch.into_event_stream(&mut buffer).unwrap().for_each(|_| async {
let value = ctrl.$name();
concat_idents::concat_idents!(notif_fn = notify_, $name {
Self::notif_fn(&signal_ctxt, value).await.ok();
});
if let Ok(value) = ctrl.$name(){
concat_idents::concat_idents!(notif_fn = $name, _changed {
Self::notif_fn(&ctrl, &signal_ctxt).await.ok();
});
if let Some(mut lock) = ctrl.config.try_lock() {
lock.$name = value;
lock.write();
}
}
}).await;
});
}