diff --git a/src/runtime2/component/control_layer.rs b/src/runtime2/component/control_layer.rs new file mode 100644 index 0000000000000000000000000000000000000000..75bd7c1f096fa10c0b355d0c4ea5577bab7eedcd --- /dev/null +++ b/src/runtime2/component/control_layer.rs @@ -0,0 +1,52 @@ +use crate::runtime2::runtime::*; +use crate::runtime2::communication::*; +use crate::runtime2::component::*; + +struct ControlEntry { + id: u32, + ack_countdown: u32, + content: ControlContent, + ack_action: ControlAction, +} + +enum ControlContent { + PeerChange(ControlPeerChange), +} + +struct ControlPeerChange { + source_port: PortId, + target_port: PortId, // if sent to this port + new_target_comp: CompId, // redirect to this component +} + +/// Action to be taken when the `Ack`s for a control entry has come in. +enum ControlAction { + Nothing, + AckOwnEntry(u32), // ack an entry we own ourselves + ScheduleComponent(CompId), // schedule a particular component for execution +} + +/// Handling/sending control messages. +pub(crate) struct ControlLayer { + id_counter: u32, + entries: Vec, +} + +impl ControlLayer { + fn handle_created_component(&mut self, creator_ctx: &CompCtx, created_ctx: &CompCtx) { + for peer in &created_ctx.peers { + // TODO: Optimize when we ourselves are the peer. + + // Create entry that will unblock the peer if it confirms that all + // of its ports have been blocked + + peer.handle.inbox.push(Message::) + } + } + + fn take_id(&mut self) -> u32 { + let id = self.id_counter; + self.id_counter += 1; + return id; + } +} \ No newline at end of file