Struct futures_glib::Executor
[−]
[src]
pub struct Executor { /* fields omitted */ }
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.
Methods
impl Executor
[src]
fn new() -> Self
Creates a new executor unassociated with any context ready to start spawning futures.
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.
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.
fn destroy(&self)
Unregister this executor and free up internal resources.
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.
fn spawn_fn<F, R>(&self, f: F) where
F: FnOnce() -> R + 'static,
R: IntoFuture<Item = (), Error = ()> + 'static,
F: FnOnce() -> R + 'static,
R: IntoFuture<Item = (), Error = ()> + 'static,
Same as spawn
above, but spawns a function that returns a future
Trait Implementations
impl Clone for Executor
[src]
fn clone(&self) -> Executor
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0
Performs copy-assignment from source
. Read more
impl<F> FutureExecutor<F> for Executor where
F: Future<Item = (), Error = ()> + 'static,
[src]
F: Future<Item = (), Error = ()> + 'static,
fn execute(&self, future: F) -> Result<(), ExecuteError<F>>
Spawns a future to run on this Executor
, typically in the "background". Read more