Struct tokio_task_pool::Pool

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

Task pool

Implementations§

source§

impl Pool

source

pub fn bounded(capacity: usize) -> Self

Creates a bounded pool (recommended)

source

pub fn unbounded() -> Self

Creates an unbounded pool

source

pub fn with_id<I: Into<String>>(self, id: I) -> Self

source

pub fn id(&self) -> Option<&str>

source

pub fn with_spawn_timeout(self, timeout: Duration) -> Self

Sets spawn timeout

(ignored for unbounded)

source

pub fn with_run_timeout(self, timeout: Duration) -> Self

Sets the default task run timeout

source

pub fn with_timeout(self, timeout: Duration) -> Self

Sets both spawn and run timeouts

source

pub fn capacity(&self) -> Option<usize>

Returns pool capacity

source

pub fn available_permits(&self) -> Option<usize>

Returns pool available task permits

source

pub fn busy_permits(&self) -> Option<usize>

Returns pool busy task permits

source

pub fn spawn<T>(&self, future: T) -> impl Future<Output = SpawnResult<T>> + '_where T: Future + Send + 'static, T::Output: Send + 'static,

Spawns a future

source

pub fn spawn_with_timeout<T>( &self, future: T, timeout: Duration ) -> impl Future<Output = SpawnResult<T>> + '_where T: Future + Send + 'static, T::Output: Send + 'static,

Spawns a future with a custom timeout

source

pub async fn spawn_task<T>(&self, task: Task<T>) -> SpawnResult<T>where T: Future + Send + 'static, T::Output: Send + 'static,

Spawns a task (a future which can have a custom ID and timeout)

Trait Implementations§

source§

impl Debug for Pool

source§

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

Formats the value using the given formatter. Read more
source§

impl Default for Pool

source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl !RefUnwindSafe for Pool

§

impl Send for Pool

§

impl Sync for Pool

§

impl Unpin for Pool

§

impl !UnwindSafe for Pool

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere 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, U> TryFrom<U> for Twhere 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 Twhere 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.