pub struct Pool { /* private fields */ }Expand description
Task pool
Implementations§
Source§impl Pool
impl Pool
pub fn with_id<I: Into<String>>(self, id: I) -> Self
pub fn id(&self) -> Option<&str>
Sourcepub fn with_spawn_timeout(self, timeout: Duration) -> Self
pub fn with_spawn_timeout(self, timeout: Duration) -> Self
Sets spawn timeout
(ignored for unbounded)
Sourcepub fn with_run_timeout(self, timeout: Duration) -> Self
pub fn with_run_timeout(self, timeout: Duration) -> Self
Sets the default task run timeout
Sourcepub fn with_timeout(self, timeout: Duration) -> Self
pub fn with_timeout(self, timeout: Duration) -> Self
Sets both spawn and run timeouts
Sourcepub fn with_no_logging_enabled(self) -> Self
pub fn with_no_logging_enabled(self) -> Self
Disables internal error logging
Sourcepub fn available_permits(&self) -> Option<usize>
pub fn available_permits(&self) -> Option<usize>
Returns pool available task permits
Sourcepub fn busy_permits(&self) -> Option<usize>
pub fn busy_permits(&self) -> Option<usize>
Returns pool busy task permits
Sourcepub fn spawn<T>(&self, future: T) -> impl Future<Output = SpawnResult<T>> + '_
pub fn spawn<T>(&self, future: T) -> impl Future<Output = SpawnResult<T>> + '_
Spawns a future
Sourcepub fn spawn_with_timeout<T>(
&self,
future: T,
timeout: Duration,
) -> impl Future<Output = SpawnResult<T>> + '_
pub fn spawn_with_timeout<T>( &self, future: T, timeout: Duration, ) -> impl Future<Output = SpawnResult<T>> + '_
Spawns a future with a custom timeout
Sourcepub async fn spawn_task<T>(&self, task: Task<T>) -> SpawnResult<T>
pub async fn spawn_task<T>(&self, task: Task<T>) -> SpawnResult<T>
Spawns a task (a future which can have a custom ID and timeout)
Sourcepub fn try_spawn<T>(&self, future: T) -> SpawnResult<T>
pub fn try_spawn<T>(&self, future: T) -> SpawnResult<T>
Tries to spawn a future if there is an available permit. Returns Error::NotAvailable if no
permit available
Sourcepub fn try_spawn_with_timeout<T>(
&self,
future: T,
timeout: Duration,
) -> SpawnResult<T>
pub fn try_spawn_with_timeout<T>( &self, future: T, timeout: Duration, ) -> SpawnResult<T>
Tries to spawn a future with a custom timeout if there is an available permit. Returns
Error::NotAvailable if no permit available
Sourcepub fn try_spawn_task<T>(&self, task: Task<T>) -> SpawnResult<T>
pub fn try_spawn_task<T>(&self, task: Task<T>) -> SpawnResult<T>
Spawns a task (a future which can have a custom ID and timeout) if there is an available
permit. Returns Error::NotAvailable if no permit available
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Pool
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> 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
Mutably borrows from an owned value. Read more