Skip to main content

ResourcePool

Trait ResourcePool 

Source
pub trait ResourcePool<T>: Send + Sync {
    // Required methods
    fn acquire<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = MapReduceResult<ResourceGuard<T>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn release(&self, resource: T);
    fn metrics(&self) -> PoolMetrics;
    fn clear<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
}
Expand description

Trait for resource pools

Required Methods§

Source

fn acquire<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = MapReduceResult<ResourceGuard<T>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Acquire a resource from the pool

Source

fn release(&self, resource: T)

Release a resource back to the pool

Source

fn metrics(&self) -> PoolMetrics

Get pool metrics

Source

fn clear<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Clear all resources from the pool

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<T, F> ResourcePool<T> for GenericResourcePool<T, F>
where T: Send + 'static, F: Fn() -> BoxFuture<'static, MapReduceResult<T>> + Send + Sync,

Source§

impl<T> ResourcePool<T> for BoundedResourcePool<T>
where T: Send + 'static,