pub struct LocalPool { /* fields omitted */ }
A single-threaded task pool for polling futures to completion.
This executor allows you to multiplex any number of tasks onto a single
thread. It's appropriate to poll strictly I/O-bound futures that do very
little work in between I/O actions.
To get a handle to the pool that implements
Spawn
, use the
spawner()
method. Because the executor is
single-threaded, it supports a special form of task spawning for non-Send
futures, via spawn_local_obj
.
[−]Create a new, empty pool of tasks.
[−]Get a clonable handle to the pool as a [Spawn
].
[−]Run all tasks in the pool to completion.
The given spawner, spawn
, is used as the default spawner for any
newly-spawned tasks. You can route these additional tasks back into
the LocalPool
by using its spawner handle:
use futures::executor::LocalPool;
let mut pool = LocalPool::new();
pool.run();
The function will block the calling thread until all tasks in the pool
are complete, including any spawned while running existing tasks.
[−]Runs all the tasks in the pool until the given future completes.
The given spawner, spawn
, is used as the default spawner for any
newly-spawned tasks. You can route these additional tasks back into
the LocalPool
by using its spawner handle:
#![feature(futures_api)]
use futures::executor::LocalPool;
use futures::future::ready;
let mut pool = LocalPool::new();
pool.run_until(my_app);
The function will block the calling thread only until the future f
completes; there may still be incomplete tasks in the pool, which will
be inert after the call completes, but can continue with further use of
run
or run_until
. While the function is running, however, all tasks
in the pool will try to make progress.
[+] Show hidden undocumented items🔬 This is a nightly-only experimental API. (try_from
)
The type returned in the event of a conversion error.
[−]🔬 This is a nightly-only experimental API. (try_from
)
[−]
[+] Show hidden undocumented items🔬 This is a nightly-only experimental API. (try_from
)
The type returned in the event of a conversion error.
[−]🔬 This is a nightly-only experimental API. (try_from
)