@@ -2358,10 +2358,28 @@ impl Commander {
2358
2358
gc_interval. set_missed_tick_behavior ( MissedTickBehavior :: Delay ) ;
2359
2359
2360
2360
loop {
2361
- select ! {
2362
- command = command_rx. recv( ) => {
2363
- let Some ( ( ack_tx, command) ) = command else { break } ;
2361
+ enum Event {
2362
+ Command ( Option < ( oneshot:: Sender < ( ) > , DemultiplexCommand ) > ) ,
2364
2363
2364
+ FromWorker ( Option < Multiplexed < WorkerMessage > > ) ,
2365
+
2366
+ // Find any channels where the receivers have been
2367
+ // dropped and clear out the sending halves.
2368
+ Gc ,
2369
+ }
2370
+ use Event :: * ;
2371
+
2372
+ let event = select ! {
2373
+ command = command_rx. recv( ) => Command ( command) ,
2374
+
2375
+ msg = from_worker_rx. recv( ) => FromWorker ( msg) ,
2376
+
2377
+ _ = gc_interval. tick( ) => Gc ,
2378
+ } ;
2379
+
2380
+ match event {
2381
+ Command ( None ) => break ,
2382
+ Command ( Some ( ( ack_tx, command) ) ) => {
2365
2383
match command {
2366
2384
DemultiplexCommand :: Listen ( job_id, waiter) => {
2367
2385
trace ! ( "adding listener for {job_id:?}" ) ;
@@ -2377,11 +2395,10 @@ impl Commander {
2377
2395
}
2378
2396
2379
2397
ack_tx. send ( ( ) ) . ok ( /* Don't care about it */ ) ;
2380
- } ,
2381
-
2382
- msg = from_worker_rx. recv( ) => {
2383
- let Some ( Multiplexed ( job_id, msg) ) = msg else { break } ;
2398
+ }
2384
2399
2400
+ FromWorker ( None ) => break ,
2401
+ FromWorker ( Some ( Multiplexed ( job_id, msg) ) ) => {
2385
2402
if let Some ( waiter) = waiting_once. remove ( & job_id) {
2386
2403
trace ! ( "notifying listener for {job_id:?}" ) ;
2387
2404
waiter. send ( msg) . ok ( /* Don't care about it */ ) ;
@@ -2397,9 +2414,7 @@ impl Commander {
2397
2414
warn ! ( "no listener for {job_id:?}" ) ;
2398
2415
}
2399
2416
2400
- // Find any channels where the receivers have been
2401
- // dropped and clear out the sending halves.
2402
- _ = gc_interval. tick( ) => {
2417
+ Gc => {
2403
2418
waiting = mem:: take ( & mut waiting)
2404
2419
. into_iter ( )
2405
2420
. filter ( |( _job_id, tx) | !tx. is_closed ( ) )
0 commit comments