diff --git a/src/runtime2/component/component.rs b/src/runtime2/component/component.rs index d68a0207767ee01904a1e6028d7742ccf9f63d8d..73ee7e4cc4ce5f8a272539990fa31a4ae357d8b0 100644 --- a/src/runtime2/component/component.rs +++ b/src/runtime2/component/component.rs @@ -1,3 +1,4 @@ +use crate::protocol::eval::EvalError; use crate::runtime2::*; use super::CompCtx; @@ -8,7 +9,17 @@ pub enum CompScheduling { Exit, } +/// Generic representation of a component (as viewed by a scheduler). pub(crate) trait Component { - fn handle_message(sched_ctx: &mut SchedulerCtx, comp_ctx: &mut CompCtx, message: Message); - fn run(sched_ctx: &mut SchedulerCtx, comp_ctx: &mut CompCtx) -> CompScheduling; + /// Called if the component is created by another component and the messages + /// are being transferred between the two. + fn adopt_message(&mut self, comp_ctx: &mut CompCtx, message: DataMessage); + + /// Called if the component receives a new message. The component is + /// responsible for deciding where that messages goes. + fn handle_message(&mut self, sched_ctx: &mut SchedulerCtx, comp_ctx: &mut CompCtx, message: Message); + + /// Called if the component's routine should be executed. The return value + /// can be used to indicate when the routine should be run again. + fn run(&mut self, sched_ctx: &mut SchedulerCtx, comp_ctx: &mut CompCtx) -> Result; } \ No newline at end of file