Struct iroh_blobs::util::local_pool::LocalPoolHandle

source ·
pub struct LocalPoolHandle { /* private fields */ }
Expand description

A handle to a LocalPool

Implementations§

source§

impl LocalPoolHandle

source

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.

source

pub fn try_spawn<T, F, Fut>(&self, gen: F) -> Result<Run<T>, SpawnError>
where F: FnOnce() -> Fut + Send + 'static, Fut: Future<Output = T> + 'static, T: Send + 'static,

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.

source

pub fn try_spawn_detached<F, Fut>(&self, gen: F) -> Result<(), SpawnError>
where F: FnOnce() -> Fut + Send + 'static, Fut: Future<Output = ()> + 'static,

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.

source

pub fn spawn<T, F, Fut>(&self, gen: F) -> Run<T>
where F: FnOnce() -> Fut + Send + 'static, Fut: Future<Output = T> + 'static, T: Send + 'static,

Spawn a task in the pool and await the result.

Like LocalPoolHandle::try_spawn, but panics if the pool is shut down.

source

pub fn spawn_detached<F, Fut>(&self, gen: F)
where F: FnOnce() -> Fut + Send + 'static, Fut: Future<Output = ()> + 'static,

Spawn a task in the pool.

Like LocalPoolHandle::try_spawn_detached, but panics if the pool is shut down.

source

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

source§

fn clone(&self) -> LocalPoolHandle

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for LocalPoolHandle

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

§

fn implicit( self, class: Class, constructed: bool, tag: u32 ) -> TaggedParser<'a, Implicit, Self, E>

source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> DynClone for T
where T: Clone,

source§

fn __clone_box(&self, _: Private) -> *mut ()

source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
§

impl<T> ErasedDestructor for T
where T: 'static,

§

impl<T> MaybeSendSync for T