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§
Sourcefn get_interruptor(&mut self) -> Box<dyn Interruptor>
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
.
Sourcefn routine<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
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§
Sourcefn interruption_level(&self) -> InterruptionLevel
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>
impl Runtime for Box<dyn Runtime>
Source§fn get_interruptor(&mut self) -> Box<dyn Interruptor>
fn get_interruptor(&mut self) -> Box<dyn Interruptor>
get_interruptor
method returns an instance of an interruptor. Read moreSource§fn routine<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn routine<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Source§fn interruption_level(&self) -> InterruptionLevel
fn interruption_level(&self) -> InterruptionLevel
interruption_level
method returns the default level at which the runtime
should be interrupted. Read more