fn new(
        new_la: &NewLocalAct,
        cancel_chan: UnboundedSender<CancelOrTimeout>,
    ) -> Result<TimeoutBag, LocalActivityResolution> {
        let (schedule_to_close, start_to_close) =
            new_la.schedule_cmd.close_timeouts.into_sched_and_start();

        let resolution = LocalActivityResolution {
            seq: new_la.schedule_cmd.seq,
            result: LocalActivityExecutionResult::timeout(TimeoutType::ScheduleToClose),
            runtime: Default::default(),
            attempt: new_la.schedule_cmd.attempt,
            backoff: None,
            original_schedule_time: Some(new_la.schedule_time),
        };
        // Remove any time already elapsed since the scheduling time
        let schedule_to_close = schedule_to_close
            .map(|s2c| s2c.saturating_sub(new_la.schedule_time.elapsed().unwrap_or_default()));
        if let Some(ref s2c) = schedule_to_close {
            if s2c.is_zero() {
                return Err(resolution);
            }
        }
        let timeout_dat = CancelOrTimeout::Timeout {
            run_id: new_la.workflow_exec_info.run_id.clone(),
            resolution,
            dispatch_cancel: true,
        };
        let start_to_close_dur_and_dat = start_to_close.map(|d| (d, timeout_dat.clone()));
        let fut_dat = schedule_to_close.map(|s2c| (s2c, timeout_dat));

        let cancel_chan_clone = cancel_chan.clone();
        let scheduling = tokio::spawn(async move {
            if let Some((timeout, dat)) = fut_dat {
                sleep(timeout).await;
                cancel_chan_clone
                    .send(dat)
                    .expect("receive half not dropped");
            }
        });
        Ok(TimeoutBag {
            sched_to_close_handle: scheduling,
            start_to_close_dur_and_dat,
            start_to_close_handle: None,
            cancel_chan,
        })
    }
/// Create new timeout tasks for the provided local activity. This must be called as soon
/// as request to schedule it arrives.
///
/// Returns error in the event the activity is *already* timed out
Create new timeout tasks for the provided local activity. This must be called as soon
as request to schedule it arrives.

Returns error in the event the activity is *already* timed out
Create new timeout tasks for the provided local activity . This must be called as soon as request to schedule it arrives . Returns error in the event the activity is * already * timed out
fn new(
        new_la: &NewLocalAct,
        cancel_chan: UnboundedSender<CancelOrTimeout>,
    ) -> Result<TimeoutBag, LocalActivityResolution> {
        let (schedule_to_close, start_to_close) =
            new_la.schedule_cmd.close_timeouts.into_sched_and_start();
        let resolution = LocalActivityResolution {
            seq: new_la.schedule_cmd.seq,
            result: LocalActivityExecutionResult::timeout(TimeoutType::ScheduleToClose),
            runtime: Default::default(),
            attempt: new_la.schedule_cmd.attempt,
            backoff: None,
            original_schedule_time: Some(new_la.schedule_time),
        };
        // Remove any time already elapsed since the scheduling time
        let schedule_to_close = schedule_to_close
            .map(|s2c| s2c.saturating_sub(new_la.schedule_time.elapsed().unwrap_or_default()));
        if let Some(ref s2c) = schedule_to_close {
            if s2c.is_zero() {
                return Err(resolution);
            }
        }
        let timeout_dat = CancelOrTimeout::Timeout {
            run_id: new_la.workflow_exec_info.run_id.clone(),
            resolution,
            dispatch_cancel: true,
        };
        let start_to_close_dur_and_dat = start_to_close.map(|d| (d, timeout_dat.clone()));
        let fut_dat = schedule_to_close.map(|s2c| (s2c, timeout_dat));
        let cancel_chan_clone = cancel_chan.clone();
        let scheduling = tokio::spawn(async move {
            if let Some((timeout, dat)) = fut_dat {
                sleep(timeout).await;
                cancel_chan_clone
                    .send(dat)
                    .expect("receive half not dropped");
            }
        });
        Ok(TimeoutBag {
            sched_to_close_handle: scheduling,
            start_to_close_dur_and_dat,
            start_to_close_handle: None,
            cancel_chan,
        })
    }
fn new ( new_la : & NewLocalAct , cancel_chan : UnboundedSender < CancelOrTimeout > , ) -> Result < TimeoutBag , LocalActivityResolution > { let ( schedule_to_close , start_to_close ) = new_la . schedule_cmd . close_timeouts . into_sched_and_start ( ) ; let resolution = LocalActivityResolution { seq : new_la . schedule_cmd . seq , result : LocalActivityExecutionResult :: timeout ( TimeoutType :: ScheduleToClose ) , runtime : Default :: default ( ) , attempt : new_la . schedule_cmd . attempt , backoff : None , original_schedule_time : Some ( new_la . schedule_time ) , } ; // Remove any time already elapsed since the scheduling time let schedule_to_close = schedule_to_close . map ( | s2c | s2c . saturating_sub ( new_la . schedule_time . elapsed ( ) . unwrap_or_default ( ) ) ) ; if let Some ( ref s2c ) = schedule_to_close { if s2c . is_zero ( ) { return Err ( resolution ) ; } } let timeout_dat = CancelOrTimeout :: Timeout { run_id : new_la . workflow_exec_info . run_id . clone ( ) , resolution , dispatch_cancel : true , } ; let start_to_close_dur_and_dat = start_to_close . map ( | d | ( d , timeout_dat . clone ( ) ) ) ; let fut_dat = schedule_to_close . map ( | s2c | ( s2c , timeout_dat ) ) ; let cancel_chan_clone = cancel_chan . clone ( ) ; let scheduling = tokio :: spawn ( async move { if let Some ( ( timeout , dat ) ) = fut_dat { sleep ( timeout ) . await ; cancel_chan_clone . send ( dat ) . expect ( " " ) ; } } ) ; Ok ( TimeoutBag { sched_to_close_handle : scheduling , start_to_close_dur_and_dat , start_to_close_handle : None , cancel_chan , } ) }
Create new timeout tasks for the provided local activity.
Create new timeout tasks for the provided local activity .
new_la
&NewLocalAct
cancel_chan
UnboundedSender<CancelOrTimeout>
new_la
&NewLocalAct
cancel_chan
UnboundedSender<CancelOrTimeout>