diff --git a/src/runtime2/inbox.rs b/src/runtime2/inbox.rs index c71ec0d15da177c50795ef34949e878eafb347ba..db5c94535cae7f96ccc86ca0bc81faa4b00df51c 100644 --- a/src/runtime2/inbox.rs +++ b/src/runtime2/inbox.rs @@ -23,13 +23,19 @@ 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 OutgoingMessage { +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)] @@ -42,12 +48,14 @@ pub struct DataMessage { pub message: ValueGroup, } +#[derive(Clone)] pub enum SyncBranchConstraint { SilentPort(PortIdLocal), BranchNumber(BranchId), PortMapping(PortIdLocal, BranchId), } +#[derive(Clone)] pub struct SyncConnectorSolution { pub connector_id: ConnectorId, pub terminating_branch_id: BranchId, @@ -55,11 +63,13 @@ pub struct SyncConnectorSolution { pub final_port_mapping: Vec<(PortIdLocal, BranchId)> } +#[derive(Clone)] pub struct SyncConnectorConstraints { pub connector_id: ConnectorId, pub constraints: Vec, } +#[derive(Clone)] pub struct SyncMessage { pub local_solutions: Vec, pub constraints: Vec, @@ -103,7 +113,7 @@ impl SyncMessage { if self.has_local_solution_for(connector_id) { return self.check_constraint(connector_id, constraint); } else { - self.add_constraint(connector_id); + self.add_constraint(connector_id, constraint); return Ok(true); } } @@ -175,6 +185,10 @@ impl SyncMessage { } } +pub struct SolutionMessage { + pub local_solutions: Vec<(ConnectorId, BranchId)>, +} + /// A control message. These might be sent by the scheduler to notify eachother /// of asynchronous state changes. pub struct ControlMessage { @@ -194,6 +208,7 @@ pub enum ControlMessageVariant { 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) }