async fn next_job_or_exit(
    rx: &mut TriggerReceiver,
    stop: &mut sync::broadcast::Receiver<()>,
) -> Job {
    if stop.try_recv().is_ok() {
        return Job::Shutdown;
    }
    // Check for shutdown or next job
    let next_job = rx.listen();
    let kill = stop.recv();
    tokio::pin!(next_job);
    tokio::pin!(kill);

    if let Either::Left((Err(_), _)) | Either::Right((_, _)) =
        futures::future::select(next_job, kill).await
    {
        Job::Shutdown
    } else {
        Job::Run
    }
}
/// Wait for the next job or exit command
Wait for the next job or exit command
Wait for the next job or exit command
async fn next_job_or_exit(
    rx: &mut TriggerReceiver,
    stop: &mut sync::broadcast::Receiver<()>,
) -> Job {
    if stop.try_recv().is_ok() {
        return Job::Shutdown;
    }
    // Check for shutdown or next job
    let next_job = rx.listen();
    let kill = stop.recv();
    tokio::pin!(next_job);
    tokio::pin!(kill);
    if let Either::Left((Err(_), _)) | Either::Right((_, _)) =
        futures::future::select(next_job, kill).await
    {
        Job::Shutdown
    } else {
        Job::Run
    }
}
async fn next_job_or_exit ( rx : & mut TriggerReceiver , stop : & mut sync :: broadcast :: Receiver < ( ) > , ) -> Job { if stop . try_recv ( ) . is_ok ( ) { return Job :: Shutdown ; } // Check for shutdown or next job let next_job = rx . listen ( ) ; let kill = stop . recv ( ) ; tokio :: pin ! ( next_job ) ; tokio :: pin ! ( kill ) ; if let Either :: Left ( ( Err ( _ ) , _ ) ) | Either :: Right ( ( _ , _ ) ) = futures :: future :: select ( next_job , kill ) . await { Job :: Shutdown } else { Job :: Run } }
Wait for the next job or exit command
Wait for the next job or exit command
rx
&mut TriggerReceiver
stop
&mut sync::broadcast::Receiver<()>
rx
&mut TriggerReceiver
stop
&mut sync::broadcast::Receiver<()>