@@ -761,6 +761,9 @@ where
761
761
762
762
let mut dyn_lane_handlers = vec ! [ ] ;
763
763
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.
764
767
macro_rules! handle_dyn_lanes {
765
768
( ) => {
766
769
for LaneSpawnRequest {
@@ -776,7 +779,7 @@ where
776
779
let io = context. add_lane( & name, kind, lane_conf) . await ?;
777
780
let descriptor = ItemDescriptor :: WarpLane {
778
781
kind,
779
- flags: ItemFlags :: TRANSIENT ,
782
+ flags: ItemFlags :: TRANSIENT , // For now, all dynamic lanes are transient.
780
783
} ;
781
784
let result = item_model. register_dynamic_item( & name, descriptor) ;
782
785
if let Ok ( id) = result {
@@ -795,6 +798,9 @@ where
795
798
} ;
796
799
}
797
800
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.
798
804
handle_dyn_lanes ! ( ) ;
799
805
800
806
// Run the agent's `on_start` event handler.
@@ -821,8 +827,11 @@ where
821
827
Ok ( _) => { }
822
828
}
823
829
830
+ // Handle any dynamic lane requests received in the `on_start` event.
824
831
handle_dyn_lanes ! ( ) ;
825
832
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.
826
835
match run_handler (
827
836
& mut ActionContext :: new (
828
837
& suspended,
0 commit comments