use nodo::prelude::*;
pub struct Terminator {
tx_control: std::sync::mpsc::SyncSender<RuntimeControl>,
}
#[derive(Config)]
pub struct TerminatorConfig {
pub step_count: usize,
}
impl Terminator {
pub fn new(tx_control: std::sync::mpsc::SyncSender<RuntimeControl>) -> Self {
Self { tx_control }
}
}
impl Codelet for Terminator {
type Status = DefaultStatus;
type Config = TerminatorConfig;
type Rx = ();
type Tx = ();
type Signals = ();
fn build_bundles(_: &Self::Config) -> (Self::Rx, Self::Tx) {
((), ())
}
fn step(&mut self, cx: Context<Self>, _: &mut Self::Rx, _: &mut Self::Tx) -> Outcome {
println!("term: {}", cx.pulse.step_count);
if cx.pulse.step_count == cx.config.step_count {
self.tx_control.send(RuntimeControl::RequestStop)?;
}
SUCCESS
}
}