[][src]Struct naja_async_runtime::Exec03

pub struct Exec03 { /* fields omitted */ }

An executor that uses futures 0.3 LocalPool or juliex threadpool under the hood. Normally you don't need to construct this yourself, just use the rt module methods to spawn futures.

Methods

impl Exec03[src]

pub fn new(config: RtConfig) -> Self[src]

Create a new Exec03 from an RtConfig configuration.

pub fn config(&self) -> &RtConfig[src]

Getter for the active executor configuration.

pub fn run(&self)[src]

Run all spawned futures to completion. Note that this does nothing for the threadpool, but if you are using a local pool, you will need to run this or futures will not be polled. This blocks the current thread.

pub fn spawn(
    &self,
    fut: impl Future<Output = ()> + 'static + Send
) -> Result<(), RtErr>
[src]

Spawn a future to be run on the default executor. Note that this requires the future to be Send in order to work for both the local pool and the threadpool. When you need to spawn futures that are not Send on the local pool, please use spawn_local.

Errors

  • When using RtConfig::Pool (currently juliex), this method is infallible.
  • When using RtConfig::Local (currently futures 0.3 LocalPool), this method can return a spawn error if the executor has been shut down. See the docs for the futures library. I haven't really found a way to trigger this error. You can call crate::rt::run and spawn again afterwards.

pub fn spawn_local(
    &self,
    fut: impl Future<Output = ()> + 'static
) -> Result<(), RtErr>
[src]

Spawn a !Send future to be run on the LocalPool (current thread). Note that the executor must be created with a local pool configuration. This will err if you try to call this on an executor set up with a threadpool.

Errors

  • When using RtConfig::Pool (currently juliex), this method will return a RtErrKind::Spawn. Since the signature doesn't require Send on the future, it can never be sent on a threadpool.
  • When using RtConfig::Local (currently futures 0.3 LocalPool), this method can return a spawn error if the executor has been shut down. See the docs for the futures library. I haven't really found a way to trigger this error. You can call rt::run and spawn again afterwards.

Trait Implementations

impl Default for Exec03[src]

impl Debug for Exec03[src]

Auto Trait Implementations

impl !Send for Exec03

impl Unpin for Exec03

impl !Sync for Exec03

impl !UnwindSafe for Exec03

impl !RefUnwindSafe for Exec03

Blanket Implementations

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Erased for T