[−][src]Trait futures::future::Executor
A trait for types which can spawn fresh futures.
This trait is typically implemented for "executors", or those types which
can execute futures to completion. Futures passed to Spawn::spawn
typically get turned into a task and are then driven to completion.
On spawn, the executor takes ownership of the future and becomes responsible
to call Future::poll()
whenever a readiness notification is raised.
Required methods
fn execute(&self, future: F) -> Result<(), ExecuteError<F>>
Spawns a future to run on this Executor
, typically in the
"background".
This function will return immediately, and schedule the future future
to run on self
. The details of scheduling and execution are left to
the implementations of Executor
, but this is typically a primary point
for injecting concurrency in a futures-based system. Futures spawned
through this execute
function tend to run concurrently while they're
waiting on events.
Errors
Implementers of this trait are allowed to reject accepting this future as well. This can happen for various reason such as:
- The executor is shut down
- The executor has run out of capacity to execute futures
The decision is left to the caller how to work with this form of error. The error returned transfers ownership of the future back to the caller.