diff --git a/src/runtime2/component/component_context.rs b/src/runtime2/component/component_context.rs index 3a72bdffe37e35420b89c72d12824a8a517d5ea1..9aab35cfd66f36787b4f538ce99d455de7475cee 100644 --- a/src/runtime2/component/component_context.rs +++ b/src/runtime2/component/component_context.rs @@ -14,6 +14,15 @@ pub enum PortInstruction { SourceLocation(ExpressionId), } +impl PortInstruction { + pub fn is_none(&self) -> bool { + match self { + PortInstruction::None => return true, + _ => return false, + } + } +} + /// Directionality of a port #[derive(Debug, PartialEq, Eq, Clone, Copy)] pub enum PortKind { @@ -29,7 +38,7 @@ pub enum PortStateFlag { Closed = 0x01, // If not closed, then the port is open BlockedDueToPeerChange = 0x02, // busy changing peers, hence use of port is temporarily blocked BlockedDueToFullBuffers = 0x04, - Transmitted, // Transmitted, so cannot be used anymore + Transmitted = 0x08, // Transmitted, so cannot be used anymore } #[derive(Copy, Clone)] @@ -49,6 +58,13 @@ impl PortState { return !self.is_closed(); } + #[inline] + pub fn can_send(&self) -> bool { + return + !self.is_set(PortStateFlag::Closed) && + !self.is_set(PortStateFlag::Transmitted); + } + #[inline] pub fn is_closed(&self) -> bool { return self.is_set(PortStateFlag::Closed);