Runtime

Trait Runtime 

Source
pub trait Runtime: Send + 'static {
    // Required methods
    fn get_interruptor(&mut self) -> Box<dyn Interruptor>;
    fn routine<'life0, 'async_trait>(
        &'life0 mut self,
    ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;

    // Provided method
    fn interruption_level(&self) -> InterruptionLevel { ... }
}
Expand description

The Runtime trait implements an asynchronous task that can be interrupted.

Consequently, this trait must implement the Send marker trait, allowing the runtime to move between different threads of the asynchronous reactor, as well as the 'static lifetime, which enables encapsulating the runtime in a Box.

Required Methods§

Source

fn get_interruptor(&mut self) -> Box<dyn Interruptor>

The get_interruptor method returns an instance of an interruptor.

The reutrned value implements the Interruptor trait and can be used by any system launching the agent’s runtime to interrupt its execution. The implementation of the Interruptor depends on the entity implementing the Runtime.

Source

fn routine<'life0, 'async_trait>( &'life0 mut self, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

The asynchronous routine method is the primary execution method of the Runtime.

It is called by the activity that runs (owns) the Runtime.

Provided Methods§

Source

fn interruption_level(&self) -> InterruptionLevel

The interruption_level method returns the default level at which the runtime should be interrupted.

Since the interruption system has different levels to allow for a graceful termination of the runtime, even if it is deeply nested in coroutines, this enables a smooth shutdown starting from the deepest level.

Trait Implementations§

Source§

impl Runtime for Box<dyn Runtime>

Source§

fn get_interruptor(&mut self) -> Box<dyn Interruptor>

The get_interruptor method returns an instance of an interruptor. Read more
Source§

fn routine<'life0, 'async_trait>( &'life0 mut self, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

The asynchronous routine method is the primary execution method of the Runtime. Read more
Source§

fn interruption_level(&self) -> InterruptionLevel

The interruption_level method returns the default level at which the runtime should be interrupted. Read more

Implementations on Foreign Types§

Source§

impl Runtime for Box<dyn Runtime>

Source§

fn get_interruptor(&mut self) -> Box<dyn Interruptor>

Source§

fn routine<'life0, 'async_trait>( &'life0 mut self, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Implementors§