@@ -30,8 +30,8 @@ use std::thread::JoinHandle;
3030pub ( crate ) struct SchedulerConnector < Inter : IsChannel , Intra : IsChannel > {
3131 local_workers : HashSet < WorkerId > ,
3232 intra_receiver : Intra :: MultiReceiver ,
33- ipc_receive_relay : PrimaryReceiveRelay < Inter , Intra > ,
34- ipc_send_relay : PrimarySendRelay < Inter > ,
33+ ipc_receive_relay : Option < PrimaryReceiveRelay < Inter , Intra > > ,
34+ ipc_send_relay : Option < PrimarySendRelay < Inter > > ,
3535 worker_sender : Intra :: MultiSender ,
3636 timeout : Duration ,
3737 worker_connector_builders : Option < HashMap < WorkerId , Builder < WorkerConnector > > > ,
@@ -45,8 +45,8 @@ impl<Inter: IsChannel, Intra: IsChannel> SchedulerConnector<Inter, Intra> {
4545 pub fn with_fields (
4646 local_workers : HashSet < WorkerId > ,
4747 intra_receiver : Intra :: MultiReceiver ,
48- ipc_receive_relay : PrimaryReceiveRelay < Inter , Intra > ,
49- ipc_send_relay : PrimarySendRelay < Inter > ,
48+ ipc_receive_relay : Option < PrimaryReceiveRelay < Inter , Intra > > ,
49+ ipc_send_relay : Option < PrimarySendRelay < Inter > > ,
5050 worker_sender : Intra :: MultiSender ,
5151 timeout : Duration ,
5252 worker_connector_builders : Option < HashMap < WorkerId , Builder < WorkerConnector > > > ,
@@ -72,7 +72,11 @@ impl<Inter: IsChannel, Intra: IsChannel> SchedulerConnector<Inter, Intra> {
7272 agent_id : AgentId ,
7373 signal : Inter :: ProtocolSignal ,
7474 ) -> Result < ( ) , Error > {
75- self . ipc_send_relay . send_to_agent ( agent_id, signal)
75+ if let Some ( relay) = self . ipc_send_relay . as_mut ( ) {
76+ relay. send_to_agent ( agent_id, signal)
77+ } else {
78+ Err ( Error :: ChannelNotFound ( ChannelId :: Agent ( agent_id) ) )
79+ }
7680 }
7781
7882 // Relay signal onto inter-process connector
@@ -103,9 +107,13 @@ impl<Inter: IsChannel, Intra: IsChannel> SchedulerConnector<Inter, Intra> {
103107
104108 pub fn run_and_connect ( & mut self ) -> Result < ( ) , Error > {
105109 debug ! ( "Starting MixedSchedulerConnector" ) ;
106- let receive_relay_handle = self . ipc_receive_relay . run_and_connect ( ) ;
107- self . relay_threads . push ( receive_relay_handle) ;
108- self . ipc_send_relay . connect ( ) ?;
110+ if let Some ( relay) = self . ipc_receive_relay . as_mut ( ) {
111+ let receive_relay_handle = relay. run_and_connect ( ) ;
112+ self . relay_threads . push ( receive_relay_handle) ;
113+ }
114+ if let Some ( relay) = self . ipc_send_relay . as_mut ( ) {
115+ relay. connect ( ) ?;
116+ }
109117 self . intra_receiver . connect_senders ( self . timeout ) ?;
110118 self . worker_sender . connect_receivers ( self . timeout )
111119 }
@@ -115,7 +123,11 @@ impl<Inter: IsChannel, Intra: IsChannel> SchedulerConnector<Inter, Intra> {
115123 }
116124
117125 fn sync_time ( & mut self ) -> Result < ( ) , Error > {
118- self . ipc_send_relay . sync_time ( )
126+ if let Some ( relay) = self . ipc_send_relay . as_mut ( ) {
127+ relay. sync_time ( )
128+ } else {
129+ Ok ( ( ) )
130+ }
119131 }
120132}
121133
@@ -131,7 +143,9 @@ impl<Inter: IsChannel, Intra: IsChannel> ConnectScheduler for SchedulerConnector
131143 fn get_connected_agent_ids ( & self ) -> Vec < AgentId > {
132144 let mut agent_ids: BTreeSet < _ > = self . worker_agent_map . values ( ) . copied ( ) . collect ( ) ;
133145 // In relayed mode, recorders are also agents we talk to.
134- agent_ids. extend ( self . ipc_send_relay . get_remote_agents ( ) ) ;
146+ if let Some ( relay) = self . ipc_send_relay . as_ref ( ) {
147+ agent_ids. extend ( relay. get_remote_agents ( ) ) ;
148+ }
135149 agent_ids. into_iter ( ) . collect ( )
136150 }
137151
@@ -157,7 +171,9 @@ impl<Inter: IsChannel, Intra: IsChannel> ConnectScheduler for SchedulerConnector
157171
158172 fn broadcast_terminate ( & mut self , signal : & Signal ) -> Result < ( ) , Error > {
159173 // Broadcast to remote agents via the IPC relay.
160- self . ipc_send_relay . broadcast ( ( * signal) . into ( ) ) ?;
174+ if let Some ( relay) = self . ipc_send_relay . as_mut ( ) {
175+ relay. broadcast ( ( * signal) . into ( ) ) ?;
176+ }
161177
162178 // Also broadcast to local workers via the MPSC sender.
163179 self . worker_sender . broadcast ( ( * signal) . into ( ) )
0 commit comments