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
typically get turned into a task and are then driven to completion.
On spawn, the executor takes ownership of the future and becomes responsible
Future::poll() whenever a readiness notification is raised.
fn execute(&self, future: F) -> Result<(), ExecuteError<F>>
Spawns a future to run on this
Executor, typically in the
This function will return immediately, and schedule the 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
execute function tend to run concurrently while they're
waiting on events.
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.