Struct iroh_blobs::util::local_pool::LocalPoolHandle
source · pub struct LocalPoolHandle { /* private fields */ }
Expand description
A handle to a LocalPool
Implementations§
source§impl LocalPoolHandle
impl LocalPoolHandle
sourcepub fn waiting_tasks(&self) -> usize
pub fn waiting_tasks(&self) -> usize
Get the number of tasks in the queue
This is not the number of tasks being executed, but the number of tasks waiting to be scheduled for execution. If this number is high, it indicates that the pool is very busy.
You might want to use this to throttle or reject requests.
sourcepub fn try_spawn<T, F, Fut>(&self, gen: F) -> Result<Run<T>, SpawnError>
pub fn try_spawn<T, F, Fut>(&self, gen: F) -> Result<Run<T>, SpawnError>
Spawn a task in the pool and return a future that resolves when the task is done.
If you don’t care about the result, prefer LocalPoolHandle::spawn_detached
since it is more efficient.
sourcepub fn try_spawn_detached<F, Fut>(&self, gen: F) -> Result<(), SpawnError>
pub fn try_spawn_detached<F, Fut>(&self, gen: F) -> Result<(), SpawnError>
Spawn a task in the pool.
The task will run to completion unless the pool is shut down or the task
panics. In case of panic, the pool will either log the panic and continue
or immediately shut down, depending on the PanicMode
.
sourcepub fn spawn<T, F, Fut>(&self, gen: F) -> Run<T> ⓘ
pub fn spawn<T, F, Fut>(&self, gen: F) -> Run<T> ⓘ
Spawn a task in the pool and await the result.
Like LocalPoolHandle::try_spawn
, but panics if the pool is shut down.
sourcepub fn spawn_detached<F, Fut>(&self, gen: F)
pub fn spawn_detached<F, Fut>(&self, gen: F)
Spawn a task in the pool.
Like LocalPoolHandle::try_spawn_detached
, but panics if the pool is shut down.
sourcepub fn try_spawn_detached_boxed(
&self,
gen: Box<dyn FnOnce() -> Pin<Box<dyn Future<Output = ()>>> + Send + 'static>
) -> Result<(), SpawnError>
pub fn try_spawn_detached_boxed( &self, gen: Box<dyn FnOnce() -> Pin<Box<dyn Future<Output = ()>>> + Send + 'static> ) -> Result<(), SpawnError>
Spawn a task in the pool.
This is like LocalPoolHandle::try_spawn_detached
, but assuming that the
generator function is already boxed. This is the lowest overhead way to
spawn a task in the pool.
Trait Implementations§
source§impl Clone for LocalPoolHandle
impl Clone for LocalPoolHandle
source§fn clone(&self) -> LocalPoolHandle
fn clone(&self) -> LocalPoolHandle
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more