Files
@ 1f78496722d1
Branch filter:
Location: CSY/reowolf/src/runtime2/communication.rs - annotation
1f78496722d1
5.6 KiB
application/rls-services+xml
feat: runtime error handling
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 | 9e771c9cf8d3 0e1a76667937 968e958c3286 0e1a76667937 d06da4e9296c d06da4e9296c d06da4e9296c d06da4e9296c c04f7fea1a62 0e1a76667937 0e1a76667937 0e1a76667937 968e958c3286 968e958c3286 0e1a76667937 0e1a76667937 0e1a76667937 0e1a76667937 0e1a76667937 9e771c9cf8d3 9e771c9cf8d3 9e771c9cf8d3 9e771c9cf8d3 9e771c9cf8d3 d06da4e9296c d06da4e9296c d06da4e9296c d06da4e9296c 0781cf1b7abf 9e771c9cf8d3 968e958c3286 968e958c3286 9e771c9cf8d3 9e771c9cf8d3 9e771c9cf8d3 11fd959b348a 11fd959b348a 11fd959b348a 11fd959b348a 11fd959b348a 11fd959b348a 11fd959b348a 11fd959b348a 11fd959b348a 11fd959b348a 11fd959b348a 11fd959b348a 11fd959b348a 11fd959b348a 11fd959b348a 11fd959b348a 11fd959b348a 11fd959b348a 11fd959b348a 11fd959b348a 0781cf1b7abf 968e958c3286 11fd959b348a 968e958c3286 968e958c3286 968e958c3286 968e958c3286 968e958c3286 d06da4e9296c d06da4e9296c d06da4e9296c d06da4e9296c d06da4e9296c d06da4e9296c d06da4e9296c d06da4e9296c d06da4e9296c d06da4e9296c 6555f56a22a9 166fbf798871 166fbf798871 166fbf798871 d06da4e9296c d06da4e9296c d06da4e9296c d06da4e9296c 166fbf798871 166fbf798871 6555f56a22a9 166fbf798871 d06da4e9296c d06da4e9296c d06da4e9296c d06da4e9296c d06da4e9296c 1f78496722d1 166fbf798871 166fbf798871 166fbf798871 166fbf798871 166fbf798871 166fbf798871 166fbf798871 166fbf798871 166fbf798871 1f78496722d1 d06da4e9296c d06da4e9296c 6555f56a22a9 d06da4e9296c 166fbf798871 166fbf798871 d06da4e9296c d06da4e9296c 6555f56a22a9 6555f56a22a9 d06da4e9296c d06da4e9296c d06da4e9296c d06da4e9296c d06da4e9296c 6555f56a22a9 d06da4e9296c d06da4e9296c d06da4e9296c d06da4e9296c d06da4e9296c 6555f56a22a9 6555f56a22a9 6555f56a22a9 6555f56a22a9 6555f56a22a9 6555f56a22a9 6555f56a22a9 6555f56a22a9 6555f56a22a9 6555f56a22a9 d06da4e9296c d06da4e9296c d06da4e9296c d06da4e9296c d06da4e9296c d06da4e9296c d06da4e9296c d06da4e9296c d06da4e9296c d06da4e9296c d06da4e9296c d06da4e9296c 0781cf1b7abf 9e771c9cf8d3 c04f7fea1a62 9e771c9cf8d3 968e958c3286 968e958c3286 9e771c9cf8d3 9e771c9cf8d3 1f78496722d1 1f78496722d1 0781cf1b7abf 968e958c3286 9e771c9cf8d3 1f78496722d1 1f78496722d1 1f78496722d1 1f78496722d1 1f78496722d1 1f78496722d1 1f78496722d1 1f78496722d1 1f78496722d1 1f78496722d1 9e771c9cf8d3 9e771c9cf8d3 d06da4e9296c d06da4e9296c d06da4e9296c d06da4e9296c d06da4e9296c d06da4e9296c d06da4e9296c d06da4e9296c d06da4e9296c d06da4e9296c d06da4e9296c 0781cf1b7abf 9e771c9cf8d3 9e771c9cf8d3 d06da4e9296c 9e771c9cf8d3 113e4349a706 0e1a76667937 0e1a76667937 968e958c3286 968e958c3286 968e958c3286 968e958c3286 968e958c3286 968e958c3286 968e958c3286 d06da4e9296c d06da4e9296c 113e4349a706 113e4349a706 968e958c3286 968e958c3286 bf4c0ee5ba65 bf4c0ee5ba65 bf4c0ee5ba65 bf4c0ee5ba65 bf4c0ee5ba65 bf4c0ee5ba65 bf4c0ee5ba65 bf4c0ee5ba65 113e4349a706 bf4c0ee5ba65 bf4c0ee5ba65 968e958c3286 968e958c3286 0e1a76667937 | use crate::protocol::eval::*;
use super::runtime::*;
use super::component::*;
// -----------------------------------------------------------------------------
// Generic types
// -----------------------------------------------------------------------------
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
pub struct PortId(pub u32);
impl PortId {
/// This value is not significant, it is chosen to make debugging easier: a
/// very large port number is more likely to shine a light on bugs.
pub fn new_invalid() -> Self {
return Self(u32::MAX);
}
}
pub struct Channel {
pub putter_id: PortId,
pub getter_id: PortId,
}
// -----------------------------------------------------------------------------
// Data messages
// -----------------------------------------------------------------------------
#[derive(Debug)]
pub struct DataMessage {
pub data_header: MessageDataHeader,
pub sync_header: MessageSyncHeader,
pub content: ValueGroup,
}
#[derive(Debug)]
pub enum PortAnnotationKind {
Getter(PortAnnotationGetter),
Putter(PortAnnotationPutter),
}
#[derive(Debug)]
pub struct PortAnnotationGetter {
pub self_comp_id: CompId,
pub self_port_id: PortId,
pub peer_comp_id: CompId,
pub peer_port_id: PortId,
}
#[derive(Debug)]
pub struct PortAnnotationPutter {
pub self_comp_id: CompId,
pub self_port_id: PortId,
}
#[derive(Debug)]
pub struct MessageDataHeader {
pub expected_mapping: Vec<(PortAnnotationKind, Option<u32>)>,
pub new_mapping: u32,
pub source_port: PortId,
pub target_port: PortId,
}
// -----------------------------------------------------------------------------
// Sync messages
// -----------------------------------------------------------------------------
#[derive(Debug)]
pub struct SyncMessage {
pub sync_header: MessageSyncHeader,
pub content: SyncMessageContent,
}
#[derive(Debug)]
pub enum SyncLocalSolutionEntry {
Putter(SyncSolutionPutterPort),
Getter(SyncSolutionGetterPort),
}
pub type SyncLocalSolution = Vec<SyncLocalSolutionEntry>;
/// Getter port in a solution. Upon receiving a message it is certain about who
/// its peer is.
#[derive(Debug)]
pub struct SyncSolutionGetterPort {
pub self_comp_id: CompId,
pub self_port_id: PortId,
pub peer_comp_id: CompId,
pub peer_port_id: PortId,
pub mapping: u32,
pub failed: bool,
}
/// Putter port in a solution. A putter may not be certain about who its peer
/// component/port is.
#[derive(Debug)]
pub struct SyncSolutionPutterPort {
pub self_comp_id: CompId,
pub self_port_id: PortId,
pub mapping: u32,
pub failed: bool,
}
#[derive(Debug)]
pub struct SyncSolutionChannel {
pub putter: Option<SyncSolutionPutterPort>,
pub getter: Option<SyncSolutionGetterPort>,
}
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
pub enum SyncRoundDecision {
None,
Solution,
Failure,
}
#[derive(Debug)]
pub struct SyncPartialSolution {
pub channel_mapping: Vec<SyncSolutionChannel>,
pub decision: SyncRoundDecision,
}
impl Default for SyncPartialSolution {
fn default() -> Self {
return Self{
channel_mapping: Vec::new(),
decision: SyncRoundDecision::None,
}
}
}
#[derive(Debug)]
pub enum SyncMessageContent {
NotificationOfLeader,
LocalSolution(CompId, SyncLocalSolution), // local solution of the specified component
PartialSolution(SyncPartialSolution), // partial solution of multiple components
GlobalSolution,
GlobalFailure,
}
// -----------------------------------------------------------------------------
// Control messages
// -----------------------------------------------------------------------------
#[derive(Debug)]
pub struct ControlMessage {
pub(crate) id: ControlId,
pub sender_comp_id: CompId,
pub target_port_id: Option<PortId>,
pub content: ControlMessageContent,
}
/// Content of a control message. If the content refers to a port then the
/// `target_port_id` field is the one that it refers to.
#[derive(Copy, Clone, Debug)]
pub enum ControlMessageContent {
Ack,
BlockPort,
UnblockPort,
ClosePort(ControlMessageClosePort),
PortPeerChangedBlock,
PortPeerChangedUnblock(PortId, CompId), // contains (new_port_id, new_component_id)
}
#[derive(Copy, Clone, Debug)]
pub struct ControlMessageClosePort {
pub closed_in_sync_round: bool, // needed to ensure correct handling of errors
}
// -----------------------------------------------------------------------------
// Messages (generic)
// -----------------------------------------------------------------------------
#[derive(Debug)]
pub struct MessageSyncHeader {
pub sync_round: u32,
pub sending_id: CompId,
pub highest_id: CompId,
}
#[derive(Debug)]
pub enum Message {
Data(DataMessage),
Sync(SyncMessage),
Control(ControlMessage),
Poll,
}
impl Message {
pub(crate) fn target_port(&self) -> Option<PortId> {
match self {
Message::Data(v) =>
return Some(v.data_header.target_port),
Message::Control(v) =>
return v.target_port_id,
Message::Sync(_) =>
return None,
Message::Poll =>
return None,
}
}
pub(crate) fn modify_target_port(&mut self, port_id: PortId) {
match self {
Message::Data(v) =>
v.data_header.target_port = port_id,
Message::Control(v) =>
v.target_port_id = Some(port_id),
Message::Sync(_) => unreachable!(), // should never be called for this message type
Message::Poll => unreachable!(),
}
}
}
|