pub struct Runtime { /* private fields */ }Expand description
A runtime is needed to schedule codelets
Example:
use core::time::Duration;
use nodo::{codelet::ScheduleBuilder, prelude::*};
use nodo_runtime::Runtime;
use nodo_std::{Sink, Source};
#[derive(Debug, Clone)]
struct Ping;
fn main() -> eyre::Result<()> {
let mut rt = Runtime::new();
// Uncomment to enable publishing inspector telemetry
// rt.enable_inspector("tcp://localhost:54399")?;
let mut source = Source::new(|| Ping).into_instance("source", ());
let mut sink = Sink::new(|x| {
println!("{x:?}");
SUCCESS
})
.into_instance("sink", ());
connect(&mut source.tx, &mut sink.rx)?;
rt.add_codelet_schedule(
ScheduleBuilder::new()
.with_period(Duration::from_millis(10))
.with_max_step_count(10)
.with(source)
.with(sink)
.into(),
);
rt.enable_terminate_on_ctrl_c();
rt.spin();
Ok(())
}Implementations§
Source§impl Runtime
impl Runtime
pub fn new() -> Self
pub fn enable_inspector(&mut self, address: &str) -> Result<()>
pub fn enable_configure(&mut self, address: &str) -> Result<()>
pub fn setup_monitors( &mut self, monitors: AppMonitorDef, ) -> Result<SharedAppMonitor>
pub fn add_codelet_schedule(&mut self, builder: ScheduleBuilder)
pub fn tx_control(&mut self) -> SyncSender<RuntimeControl>
Sourcepub fn enable_terminate_on_ctrl_c(&mut self)
pub fn enable_terminate_on_ctrl_c(&mut self)
If called the program will stop when Ctrl+C is pressed
pub fn spin(&mut self)
pub fn wait_for_ctrl_c(&mut self)
👎Deprecated since 0.2.0: use
enable_terminate_on_ctrl_c insteadAuto Trait Implementations§
impl Freeze for Runtime
impl !RefUnwindSafe for Runtime
impl Send for Runtime
impl !Sync for Runtime
impl Unpin for Runtime
impl !UnwindSafe for Runtime
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more