Skip to content

Commit 69f0d22

Browse files
committed
Adds comments for dynamic lane registration.
1 parent 9de4da3 commit 69f0d22

File tree

1 file changed

+10
-1
lines changed
  • server/swimos_agent/src/agent_model

1 file changed

+10
-1
lines changed

server/swimos_agent/src/agent_model/mod.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -761,6 +761,9 @@ where
761761

762762
let mut dyn_lane_handlers = vec![];
763763

764+
// This handles any requests that have been received to open dynamic lanes. Due to complex, interleaved
765+
// borrows of non-send variables, it is impractical to extract this out as a function. This macro is a
766+
// compromise to avoid duplicating the block of code.
764767
macro_rules! handle_dyn_lanes {
765768
() => {
766769
for LaneSpawnRequest {
@@ -776,7 +779,7 @@ where
776779
let io = context.add_lane(&name, kind, lane_conf).await?;
777780
let descriptor = ItemDescriptor::WarpLane {
778781
kind,
779-
flags: ItemFlags::TRANSIENT,
782+
flags: ItemFlags::TRANSIENT, // For now, all dynamic lanes are transient.
780783
};
781784
let result = item_model.register_dynamic_item(&name, descriptor);
782785
if let Ok(id) = result {
@@ -795,6 +798,9 @@ where
795798
};
796799
}
797800

801+
// Handle any dynamic lane requests received in the `on_init` event. We don't trigger the
802+
// corresponding event handlers yet to respect the contract that `on_start` is the first
803+
// event handler to be run in the agent.
798804
handle_dyn_lanes!();
799805

800806
// Run the agent's `on_start` event handler.
@@ -821,8 +827,11 @@ where
821827
Ok(_) => {}
822828
}
823829

830+
// Handle any dynamic lane requests received in the `on_start` event.
824831
handle_dyn_lanes!();
825832

833+
// Run all of the event handlers associated with requests for dynamic lanes. These could have bee
834+
// generated by either (or both) of the `on_init` and `on_start` events.
826835
match run_handler(
827836
&mut ActionContext::new(
828837
&suspended,

0 commit comments

Comments
 (0)