[−][src]Enum spirit_tokio::runtime::Tokio
A spirit
Extension
to inject a tokio
runtime.
This, when inserted into spirit Builder
with the
with_singleton
will provide the application with a tokio
runtime.
This will:
- Run the application body inside the runtime (to allow spawning tasks and creating tokio resources).
- Run the configuration/termination/signal hooks inside the async context of the runtime (for similar reasons).
- Keep the runtime running until
terminate
is invoked (either explicitly or by CTRL+C or similar).
A default instance (Tokio::Default
) is inserted by pipelines containing the
FutureInstaller
.
Variants (Non-exhaustive)
Provides the equivalent of Runtime::new
.
Allows the caller to provide arbitrary constructor for the Runtime
.
This variant also allows creating the basic (non-threaded) scheduler if needed. Note that some operations with such runtime are prone to cause deadlocks.
FromCfg(Box<dyn FnMut(&O, &C) -> Config + Send>, Box<dyn FnMut(Builder) -> Result<Runtime, AnyError> + Send>)
Uses configuration for constructing the Runtime
.
This'll use the extractor (the first closure) to get a Config
, create a Builder
based on that. It'll explicitly enable all the drivers and enable threaded runtime. Then it
calls the postprocessor (the second closure) to turn it into the Runtime
.
This is the more general form. If you're fine with just basing it on the configuration
without much tweaking, you can use Tokio::from_cfg
(which will create this variant with
reasonable value of preprocessor).
This is available only with the [rt-from-cfg
] feature enabled.
Implementations
impl<O, C> Tokio<O, C>
[src]
pub fn from_cfg<E>(extractor: E) -> Self where
E: FnMut(&C) -> Config + Send + 'static,
[src]
E: FnMut(&C) -> Config + Send + 'static,
Simplified construction from configuration.
This is similar to Tokio::FromCfg
. However, the extractor takes only the configuration
structure, not the command line options. Furthermore, post-processing is simply calling
Builder::build
, without a chance to tweak.
pub fn create(&mut self, opts: &O, cfg: &Arc<C>) -> Result<Runtime, AnyError>
[src]
Method to create the runtime.
This can be used when not taking advantage of the spirit auto-management features.
Trait Implementations
impl<O, C> Default for Tokio<O, C>
[src]
impl<E> Extension<E> for Tokio<E::Opts, E::Config> where
E: Extensible<Ok = E>,
E::Config: DeserializeOwned + Send + Sync + 'static,
E::Opts: StructOpt + Send + Sync + 'static,
[src]
E: Extensible<Ok = E>,
E::Config: DeserializeOwned + Send + Sync + 'static,
E::Opts: StructOpt + Send + Sync + 'static,
Auto Trait Implementations
impl<O, C> !RefUnwindSafe for Tokio<O, C>
impl<O, C> Send for Tokio<O, C>
impl<O, C> !Sync for Tokio<O, C>
impl<O, C> Unpin for Tokio<O, C>
impl<O, C> !UnwindSafe for Tokio<O, C>
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<B, F, R> Extension<B> for F where
F: FnOnce(B) -> R,
R: IntoResult<B>,
[src]
F: FnOnce(B) -> R,
R: IntoResult<B>,
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> IntoResult<T> for T
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,