pub struct LocalPool { /* private fields */ }Expand description
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.
Implementations§
Source§impl LocalPool
impl LocalPool
Sourcepub fn spawner(&self) -> LocalSpawner
pub fn spawner(&self) -> LocalSpawner
Get a clonable handle to the pool as a Spawn.
Sourcepub fn run<P: Park>(&mut self, park: &mut P, enter: &mut Enter)
pub fn run<P: Park>(&mut self, park: &mut P, enter: &mut Enter)
Run all tasks in the pool to completion.
The function will block the calling thread until all tasks in the pool completed, including any spawned while running existing tasks.
Sourcepub fn run_until<P: Park, F: Future>(
&mut self,
park: &mut P,
enter: &mut Enter,
future: F,
) -> F::Output
pub fn run_until<P: Park, F: Future>( &mut self, park: &mut P, enter: &mut Enter, future: F, ) -> F::Output
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:
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
one of the pool’s run or poll methods. While the function is running,
however, all tasks in the pool will try to make progress.
Sourcepub fn poll_pool(&mut self, cx: &mut Context<'_>) -> Poll<()>
pub fn poll_pool(&mut self, cx: &mut Context<'_>) -> Poll<()>
Make progress on entire pool, polling each spawend task at most once.
Becomes Ready when all tasks are completed.
Sourcepub fn spawn(&self, future: LocalFutureObj<'static, ()>)
pub fn spawn(&self, future: LocalFutureObj<'static, ()>)
Spawn future on pool
Trait Implementations§
Source§impl LocalSpawn for LocalPool
impl LocalSpawn for LocalPool
Source§fn spawn_local_obj(
&mut self,
future: LocalFutureObj<'static, ()>,
) -> Result<(), SpawnError>
fn spawn_local_obj( &mut self, future: LocalFutureObj<'static, ()>, ) -> Result<(), SpawnError>
Source§fn status_local(&self) -> Result<(), SpawnError>
fn status_local(&self) -> Result<(), SpawnError>
Auto Trait Implementations§
impl Freeze for LocalPool
impl !RefUnwindSafe for LocalPool
impl !Send for LocalPool
impl !Sync for LocalPool
impl Unpin for LocalPool
impl !UnwindSafe for LocalPool
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<Sp> LocalSpawnExt for Spwhere
Sp: LocalSpawn + ?Sized,
impl<Sp> LocalSpawnExt for Spwhere
Sp: LocalSpawn + ?Sized,
Source§fn spawn_local<Fut>(&mut self, future: Fut) -> Result<(), SpawnError>
fn spawn_local<Fut>(&mut self, future: Fut) -> Result<(), SpawnError>
() to
completion. Read more