Struct Executor

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

A handle through which futures can be executed.

This structure is an instance of a Source which can be used to manage the execution of a number of futures within.

Implementations§

Source§

impl Executor

Source

pub fn new() -> Self

Creates a new executor unassociated with any context ready to start spawning futures.

Source

pub fn attach(&self, cx: &MainContext)

Attaches this executor to a context, returning the token that it was assigned.

This is required to be called for futures to be completed.

Source

pub fn remote(&self) -> Remote

Generates a remote handle to this event loop which can be used to spawn tasks from other threads into this event loop.

Source

pub fn destroy(&self)

Unregister this executor and free up internal resources.

Source

pub fn spawn<F: Future<Item = (), Error = ()> + 'static>(&self, future: F)

Spawns a new future onto the event loop that this source is associated with.

This function is given a future which is then spawned onto the glib event loop. The glib event loop will listen for incoming events of when futures are ready and attempt to push them all to completion.

The futures spawned here will not be completed unless the attach function is called above.

Source

pub fn spawn_fn<F, R>(&self, f: F)
where F: FnOnce() -> R + 'static, R: IntoFuture<Item = (), Error = ()> + 'static,

Same as spawn above, but spawns a function that returns a future

Trait Implementations§

Source§

impl Clone for Executor

Source§

fn clone(&self) -> Executor

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<F> Executor<F> for Executor
where F: Future<Item = (), Error = ()> + 'static,

Source§

fn execute(&self, future: F) -> Result<(), ExecuteError<F>>

Spawns a future to run on this Executor, typically in the “background”. Read more

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.