async fn run_task_until_cancelled<T>(
        mut task: T,
        task_id: T::TaskId,
        tx: Sender<(T::TaskId, T::TaskResult)>,
        rx: Receiver<BroadcastMsg>,
        sem: Arc<Semaphore>,
    ) where
        T: ProverTask,
    {
        let task_fut = task.run(task_id, sem).fuse();
        let watchdog_fut = Self::watchdog(rx).fuse();
        pin_mut!(task_fut, watchdog_fut);
        select! {
            _ = watchdog_fut => {
                // A stop message is received.
            }
            res = task_fut => {
                // Task finishes running, send the result to parent thread.
                let _ = tx.send((task_id, res));
            },
        }
    }
// Run two async tasks, listening on broadcast channel and running the task, until
// either the task finishes running, or a stop message is received.
Run two async tasks, listening on broadcast channel and running the task, until
either the task finishes running, or a stop message is received.
Run two async tasks listening on broadcast channel and running the task until either the task finishes running or a stop message is received .
async fn run_task_until_cancelled<T>(
        mut task: T,
        task_id: T::TaskId,
        tx: Sender<(T::TaskId, T::TaskResult)>,
        rx: Receiver<BroadcastMsg>,
        sem: Arc<Semaphore>,
    ) where
        T: ProverTask,
    {
        let task_fut = task.run(task_id, sem).fuse();
        let watchdog_fut = Self::watchdog(rx).fuse();
        pin_mut!(task_fut, watchdog_fut);
        select! {
            _ = watchdog_fut => {
                // A stop message is received.
            }
            res = task_fut => {
                // Task finishes running, send the result to parent thread.
                let _ = tx.send((task_id, res));
            },
        }
    }
async fn run_task_until_cancelled < T > ( mut task : T , task_id : T :: TaskId , tx : Sender < ( T :: TaskId , T :: TaskResult ) > , rx : Receiver < BroadcastMsg > , sem : Arc < Semaphore > , ) where T : ProverTask , { let task_fut = task . run ( task_id , sem ) . fuse ( ) ; let watchdog_fut = Self :: watchdog ( rx ) . fuse ( ) ; pin_mut ! ( task_fut watchdog_fut ) ; select ! { watchdog_fut { // A stop message is received. } res task_fut { // Task finishes running, send the result to parent thread. let tx send ( ( task_id res ) ) } } }
Run two async tasks, listening on broadcast channel and running the task, until
either the task finishes running, or a stop message is received.
Run two async tasks listening on broadcast channel and running the task until either the task finishes running or a stop message is received .
task
T
task_id
T::TaskId
tx
Sender<(T::TaskId, T::TaskResult)>
rx
Receiver<BroadcastMsg>
sem
Arc<Semaphore>