pub fn run(
        self,
        counter_tx: CounterTx,
        generation: u64,
    ) -> (Task<Result<(ActorRunner, u64), Aborted>>, AbortHandle) {
        let (abort_handle, abort_registration) = AbortHandle::new_pair();
        let fut = async move {
            let mut local_count: u64 = 0;
            loop {
                if let Some(delay) = self.delay {
                    debug!(
                        "[{}][{}][{}] Sleeping for {:?}",
                        generation, self.name, local_count, delay
                    );
                    Timer::new(Time::after(delay.into())).await;
                }

                debug!("[{}][{}][{}] Performing...", generation, self.name, local_count);

                // Lock on the actor and perform. This prevents the environment from
                // modifying the actor until the operation is complete.
                let result = {
                    let mut actor = self.actor.lock().await;
                    actor.perform().await
                };

                match result {
                    Ok(()) => {
                        // Count this iteration towards the global count
                        let _ = counter_tx.unbounded_send(self.name.clone());
                        debug!("[{}][{}][{}] Done!", generation, self.name, local_count);
                    }
                    Err(ActorError::DoNotCount) => {
                        // Do not count this iteration towards global count
                    }
                    Err(ActorError::ResetEnvironment) => {
                        // Actor needs environment to be reset. Stop the runner
                        debug!(
                            "[{}][{}][{}] Reset Environment!",
                            generation, self.name, local_count
                        );
                        return (self, generation);
                    }
                }

                local_count += 1;
            }
        };
        (Task::blocking(Abortable::new(fut, abort_registration)), abort_handle)
    }
/// Run the actor on a new thread indefinitely for the given generation.
/// The runner will stop if the actor requests an environment reset.
Run the actor on a new thread indefinitely for the given generation.
The runner will stop if the actor requests an environment reset.
Run the actor on a new thread indefinitely for the given generation . The runner will stop if the actor requests an environment reset .
pub fn run(
        self,
        counter_tx: CounterTx,
        generation: u64,
    ) -> (Task<Result<(ActorRunner, u64), Aborted>>, AbortHandle) {
        let (abort_handle, abort_registration) = AbortHandle::new_pair();
        let fut = async move {
            let mut local_count: u64 = 0;
            loop {
                if let Some(delay) = self.delay {
                    debug!(
                        "[{}][{}][{}] Sleeping for {:?}",
                        generation, self.name, local_count, delay
                    );
                    Timer::new(Time::after(delay.into())).await;
                }
                debug!("[{}][{}][{}] Performing...", generation, self.name, local_count);
                // Lock on the actor and perform. This prevents the environment from
                // modifying the actor until the operation is complete.
                let result = {
                    let mut actor = self.actor.lock().await;
                    actor.perform().await
                };
                match result {
                    Ok(()) => {
                        // Count this iteration towards the global count
                        let _ = counter_tx.unbounded_send(self.name.clone());
                        debug!("[{}][{}][{}] Done!", generation, self.name, local_count);
                    }
                    Err(ActorError::DoNotCount) => {
                        // Do not count this iteration towards global count
                    }
                    Err(ActorError::ResetEnvironment) => {
                        // Actor needs environment to be reset. Stop the runner
                        debug!(
                            "[{}][{}][{}] Reset Environment!",
                            generation, self.name, local_count
                        );
                        return (self, generation);
                    }
                }
                local_count += 1;
            }
        };
        (Task::blocking(Abortable::new(fut, abort_registration)), abort_handle)
    }
pub fn run ( self , counter_tx : CounterTx , generation : u64 , ) -> ( Task < Result < ( ActorRunner , u64 ) , Aborted > > , AbortHandle ) { let ( abort_handle , abort_registration ) = AbortHandle :: new_pair ( ) ; let fut = async move { let mut local_count : u64 = 0 ; loop { if let Some ( delay ) = self . delay { debug ! ( " " generation self name local_count delay ) ; Timer :: new ( Time :: after ( delay . into ( ) ) ) . await ; } debug ! ( " " generation self name local_count ) ; // Lock on the actor and perform. This prevents the environment from // modifying the actor until the operation is complete. let result = { let mut actor = self . actor . lock ( ) . await ; actor . perform ( ) . await } ; match result { Ok ( ( ) ) => { // Count this iteration towards the global count let _ = counter_tx . unbounded_send ( self . name . clone ( ) ) ; debug ! ( " " generation self name local_count ) ; } Err ( ActorError :: DoNotCount ) => { // Do not count this iteration towards global count } Err ( ActorError :: ResetEnvironment ) => { // Actor needs environment to be reset. Stop the runner debug ! ( " " generation self name local_count ) ; return ( self , generation ) ; } } local_count += 1 ; } } ; ( Task :: blocking ( Abortable :: new ( fut , abort_registration ) ) , abort_handle ) }
Run the actor on a new thread indefinitely for the given generation.
Run the actor on a new thread indefinitely for the given generation .
self
counter_tx
CounterTx
generation
u64
self
counter_tx
CounterTx
generation
u64