diff --git a/src/runtime2/inbox.rs b/src/runtime2/inbox.rs index fbc1130d314a9db50de959332eee57d02652bef8..b07d021190240a8c06e000f0bc4398e19bddb273 100644 --- a/src/runtime2/inbox.rs +++ b/src/runtime2/inbox.rs @@ -13,11 +13,11 @@ within a certain sync-round. **/ use std::collections::VecDeque; -use std::sync::{RwLock, RwLockReadGuard, Mutex}; -use std::sync::atomic::{AtomicUsize, Ordering}; +use std::sync::Mutex; use crate::protocol::eval::ValueGroup; -use super::connector::{BranchId, PortIdLocal}; +use super::connector::BranchId; +use super::port::PortIdLocal; use super::global_store::ConnectorId; /// A message that has been delivered (after being imbued with the receiving @@ -143,7 +143,7 @@ impl SyncMessage { match constraint { SyncBranchConstraint::SilentPort(silent_port_id) => { for (port_id, mapped_id) in &entry.final_port_mapping { - if port_id == silent_port_id { + if *port_id == silent_port_id { // If silent, then mapped ID is invalid return Ok(!mapped_id.is_valid()) } @@ -167,6 +167,7 @@ impl SyncMessage { } } +#[derive(Clone)] pub struct SolutionMessage { pub comparison_number: u64, pub connector_origin: ConnectorId, @@ -176,11 +177,13 @@ pub struct SolutionMessage { /// A control message. These might be sent by the scheduler to notify eachother /// of asynchronous state changes. +#[derive(Clone)] pub struct ControlMessage { pub id: u32, // generic identifier, used to match request to response pub content: ControlMessageVariant, } +#[derive(Clone)] pub enum ControlMessageVariant { ChangePortPeer(PortIdLocal, ConnectorId), // specified port has a new peer, sent to owner of said port Ack, // acknowledgement of previous control message, matching occurs through control message ID. @@ -258,7 +261,7 @@ impl PrivateInbox { for existing in self.messages.iter() { if existing.sender_prev_branch_id == message.sender_prev_branch_id && existing.sender_cur_branch_id == message.sender_cur_branch_id && - existing.receiving_port == message.receiving_port { + existing.sending_port == message.sending_port { // Message was already received return; } @@ -313,10 +316,10 @@ pub struct InboxMessageIter<'i> { match_prev_branch_id: BranchId, } -impl<'m: 'i, 'i> Iterator for InboxMessageIter<'i> { - type Item = &'m DataMessage; +impl<'i> Iterator for InboxMessageIter<'i> { + type Item = &'i DataMessage; - fn next(&'m mut self) -> Option { + fn next(&mut self) -> Option { // Loop until match is found or at end of messages while self.next_index < self.max_index { let cur_message = &self.messages[self.next_index];