diff --git a/src/runtime2/inbox.rs b/src/runtime2/inbox.rs index db5c94535cae7f96ccc86ca0bc81faa4b00df51c..fbc1130d314a9db50de959332eee57d02652bef8 100644 --- a/src/runtime2/inbox.rs +++ b/src/runtime2/inbox.rs @@ -20,29 +20,11 @@ use crate::protocol::eval::ValueGroup; use super::connector::{BranchId, PortIdLocal}; use super::global_store::ConnectorId; -/// A message prepared by a connector. Waiting to be picked up by the runtime to -/// be sent to another connector. -#[derive(Clone)] -pub struct OutgoingDataMessage { - pub sending_port: PortIdLocal, - pub sender_prev_branch_id: BranchId, // may be invalid, implying no prev branch id - pub sender_cur_branch_id: BranchId, // always valid - pub message: ValueGroup, -} - -pub enum OutgoingMessage { - Data(OutgoingDataMessage), - Sync(SyncMessage), - Solution(SolutionMessage), -} - /// A message that has been delivered (after being imbued with the receiving /// port by the scheduler) to a connector. #[derive(Clone)] pub struct DataMessage { - pub sending_connector: ConnectorId, pub sending_port: PortIdLocal, - pub receiving_port: PortIdLocal, pub sender_prev_branch_id: BranchId, pub sender_cur_branch_id: BranchId, pub message: ValueGroup, @@ -186,14 +168,16 @@ impl SyncMessage { } pub struct SolutionMessage { + pub comparison_number: u64, + pub connector_origin: ConnectorId, pub local_solutions: Vec<(ConnectorId, BranchId)>, + pub to_visit: Vec, } /// A control message. These might be sent by the scheduler to notify eachother /// of asynchronous state changes. pub struct ControlMessage { pub id: u32, // generic identifier, used to match request to response - pub sender: ConnectorId, pub content: ControlMessageVariant, } @@ -202,15 +186,21 @@ pub enum ControlMessageVariant { Ack, // acknowledgement of previous control message, matching occurs through control message ID. } -/// Generic message in the `PublicInbox`, handled by the scheduler (which takes -/// out and handles all control message and potential routing). The correctly -/// addressed `Data` variants will end up at the connector. -pub enum Message { - Data(DataMessage), // data message, handled by connector - Sync(SyncMessage), // sync message, handled by both connector/scheduler - Solution(SolutionMessage), // solution message, finishing a sync round - Control(ControlMessage), // control message, handled by scheduler - Ping, // ping message, intentionally waking up a connector (used for native connectors) +/// Generic message contents. +#[derive(Clone)] +pub enum MessageContents { + Data(DataMessage), // data message, handled by connector + Sync(SyncMessage), // sync message, handled by both connector/scheduler + RequestCommit(SolutionMessage), // solution message, requesting participants to commit + ConfirmCommit(SolutionMessage), // solution message, confirming a solution everyone committed to + Control(ControlMessage), // control message, handled by scheduler + Ping, // ping message, intentionally waking up a connector (used for native connectors) +} + +pub struct Message { + pub sending_connector: ConnectorId, + pub receiving_port: PortIdLocal, // may be invalid (in case of messages targeted at the connector) + pub contents: MessageContents, } /// The public inbox of a connector. The thread running the connector that owns