diff --git a/src/runtime2/inbox.rs b/src/runtime2/inbox.rs index 26983cc5a008de576fe4860a3c1e1b0fbf189777..c489561f96788af0e87b555f3c16628822032599 100644 --- a/src/runtime2/inbox.rs +++ b/src/runtime2/inbox.rs @@ -2,6 +2,8 @@ use std::sync::Mutex; use std::collections::VecDeque; use crate::protocol::eval::ValueGroup; +use crate::runtime2::consensus::SolutionCombiner; +use crate::runtime2::port::ChannelId; use super::ConnectorId; use super::branch::BranchId; @@ -11,8 +13,8 @@ use super::port::PortIdLocal; // TODO: Remove Debug derive from all types #[derive(Debug, Copy, Clone)] -pub(crate) struct PortAnnotation { - pub port_id: PortIdLocal, +pub(crate) struct ChannelAnnotation { + pub channel_id: ChannelId, pub registered_id: Option, pub expected_firing: Option, } @@ -50,7 +52,7 @@ pub(crate) struct SyncHeader { /// The header added to data messages #[derive(Debug, Clone)] pub(crate) struct DataHeader { - pub expected_mapping: Vec, + pub expected_mapping: Vec, pub sending_port: PortIdLocal, pub target_port: PortIdLocal, pub new_mapping: BranchMarker, @@ -87,19 +89,37 @@ pub(crate) struct DataMessage { } #[derive(Debug)] -pub(crate) enum SyncContent { +pub(crate) enum SyncCompContent { + LocalFailure, // notifying leader that component has failed (e.g. timeout, whatever) LocalSolution(LocalSolution), // sending a local solution to the leader + PartialSolution(SolutionCombiner), // when new leader is detected, forward all local results GlobalSolution(GlobalSolution), // broadcasting to everyone + GlobalFailure, // broadcasting to everyone + AckFailure, // acknowledgement of failure to leader Notification, // just a notification (so purpose of message is to send the SyncHeader) + Presence(ConnectorId, Vec), // notifying leader of component presence (needed to ensure failing a round involves all components in a sync round) } /// A sync message is a message that is intended only for the consensus -/// algorithm. +/// algorithm. The message goes directly to a component. #[derive(Debug)] -pub(crate) struct SyncMessage { +pub(crate) struct SyncCompMessage { pub sync_header: SyncHeader, pub target_component_id: ConnectorId, - pub content: SyncContent, + pub content: SyncCompContent, +} + +#[derive(Debug)] +pub(crate) enum SyncPortContent { + NotificationWave, +} + +#[derive(Debug)] +pub(crate) struct SyncPortMessage { + pub sync_header: SyncHeader, + pub source_port: PortIdLocal, + pub target_port: PortIdLocal, + pub content: SyncPortContent, } /// A control message is a message intended for the scheduler that is executing @@ -123,7 +143,8 @@ pub(crate) enum ControlContent { #[derive(Debug)] pub(crate) enum Message { Data(DataMessage), - Sync(SyncMessage), + SyncComp(SyncCompMessage), + SyncPort(SyncPortMessage), Control(ControlMessage), }