diff --git a/src/runtime2/scheduler.rs b/src/runtime2/scheduler.rs index a17d66cc0b843cdbd460a5bc7518bd137b1a8efd..44e212f8d94a70c3bcd30bdd64c4cf168ea5433a 100644 --- a/src/runtime2/scheduler.rs +++ b/src/runtime2/scheduler.rs @@ -1,6 +1,7 @@ use std::collections::VecDeque; use std::sync::Arc; use std::sync::atomic::Ordering; +use crate::runtime2::inbox2::{DataMessageFancy, MessageFancy}; use super::{ScheduledConnector, RuntimeInner, ConnectorId, ConnectorKey, ConnectorVariant}; use super::port::{Port, PortState, PortIdLocal}; @@ -405,7 +406,7 @@ pub(crate) struct ComponentCtxFancy { // Mostly managed by the scheduler pub(crate) id: ConnectorId, ports: Vec, - inbox_messages: Vec, // never control or ping messages + inbox_messages: Vec, // never control or ping messages inbox_len_read: usize, // Submitted by the component is_in_sync: bool, @@ -499,19 +500,19 @@ impl ComponentCtxFancy { /// Retrieves messages matching a particular port and branch id. But only /// those messages that have been previously received with /// `read_next_message`. - pub(crate) fn get_read_data_messages(&self, match_port_id: PortIdLocal, match_prev_branch_id: BranchId) -> MessagesIter { + pub(crate) fn get_read_data_messages(&self, match_port_id: PortIdLocal) -> MessagesIter { return MessagesIter { messages: &self.inbox_messages, next_index: 0, max_index: self.inbox_len_read, - match_port_id, match_prev_branch_id + match_port_id }; } /// Retrieves the next unread message from the inbox `None` if there are no /// (new) messages to read. // TODO: Fix the clone of the data message, entirely unnecessary - pub(crate) fn read_next_message(&mut self) -> Option { + pub(crate) fn read_next_message(&mut self) -> Option { if !self.is_in_sync { return None; } if self.inbox_len_read == self.inbox_messages.len() { return None; } @@ -533,22 +534,21 @@ impl ComponentCtxFancy { } pub(crate) struct MessagesIter<'a> { - messages: &'a [Message], + messages: &'a [MessageFancy], next_index: usize, max_index: usize, match_port_id: PortIdLocal, - match_prev_branch_id: BranchId, } impl<'a> Iterator for MessagesIter<'a> { - type Item = &'a DataMessage; + type Item = &'a DataMessageFancy; fn next(&mut self) -> Option { // Loop until match is found or at end of messages while self.next_index < self.max_index { let message = &self.messages[self.next_index]; - if let MessageContents::Data(data_message) = &message.contents { - if message.receiving_port == self.match_port_id && data_message.sender_prev_branch_id == self.match_prev_branch_id { + if let MessageFancy::Data(message) = &message { + if message.data_header.target_port == self.match_port_id { // Found a match self.next_index += 1; return Some(data_message);