Skip to main content

AgnosticExecutorManager

Struct AgnosticExecutorManager 

Source
pub struct AgnosticExecutorManager { /* private fields */ }
Expand description

An AgnosticExecutorManager is configured on creation for a specific executor and it allows you get the the general and local executor, set it as global executor, and of course, start the executor.

Implementations§

Source§

impl AgnosticExecutorManager

Source

pub fn get_executor(&self) -> AgnosticExecutor

Get the executor of this manager as an AgnosticExecutor. This is needed if you need to spawn new tasks, and it be easily stored, cloned and send across threads to have it available where ever you need to spawn a new tasks or interact with the executor.

Source

pub fn get_local_executor(&mut self) -> LocalAgnosticExecutor

Get the local executor of this manager as a LocalAgnosticExecutor. A local executor is similar to the general executor but it allows to spawn tasks that are not send. The drawback is that, even tough you can store and clone a LocalAgnosticExecutor, you cannot send it to other threads.

Source

pub fn on_finish<F>(&mut self, cb: F)
where F: FnOnce() + 'static,

Sets up a callback to be called when the executor finishes. It can only be called once. This is needed because on wasm the start() call might finish before it’s future completes and we might need a way to detect completion.

Source

pub fn set_as_global(&self)

Sets this executor as the global executor to be used with the global crate functions get_global_executor, spawn and spawn_blocking. You still need to start the executor after setting it as global. This can only be called once.

Source

pub fn start<F>(self, future: F)
where F: Future<Output = ()> + 'static,

Start the executor with the provided future. This future doesn’t need to be Send, but it needs to be ’static. You can use async move {…} to achieve this if needed. Note that in wasm the call might finish before the future has completely executed due to the non-blocking nature of the environment, so don’t depend on this. With the other executors you can depend on the fact that start is blocking, but the on_finish callback is called anyway.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<S, T> Upcast<T> for S
where T: UpcastFrom<S> + ?Sized, S: ?Sized,

Source§

fn upcast(&self) -> &T
where Self: ErasableGeneric, T: ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider ref type within the Wasm bindgen generics type system. Read more
Source§

fn upcast_into(self) -> T
where Self: Sized + ErasableGeneric, T: ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider type within the Wasm bindgen generics type system. Read more