Loading files
This file is pinned to the selected release. Download the original to open it in your design tool.
8387e0397This file is pinned to the selected release. Download the original to open it in your design tool.
use planner_app::{Effect, Event, Planner};
use std::sync::Arc;
use anyhow::anyhow;
use crossbeam_channel::Sender;
use tracing::debug;
pub type Core = Arc<crux_core::Core<Effect, Planner>>;
pub fn new() -> Core {
Arc::new(crux_core::Core::new())
}
pub fn update(core: &Core, event: Event, tx: &Arc<Sender<Effect>>) -> anyhow::Result<()> {
debug!("event: {:?}", event);
for effect in core.process_event(event) {
process_effect(core, effect, tx)?;
}
Ok(())
}
// TODO investigate why we need two 'effect processing' routines, see 'run_loop'
pub fn process_effect(_core: &Core, effect: Effect, tx: &Arc<Sender<Effect>>) -> anyhow::Result<()> {
debug!("core::process_effect. effect: {:?}", effect);
tx.send(effect)
.map_err(|e| anyhow!("{:?}", e))?;
Ok(())
}