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
impl Executor
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new executor unassociated with any context ready to start spawning futures.
Sourcepub fn attach(&self, cx: &MainContext)
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.
Sourcepub fn remote(&self) -> Remote
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.
Sourcepub fn spawn<F: Future<Item = (), Error = ()> + 'static>(&self, future: F)
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.