piscina
A simple generic pool that supports both sync and async.
This crate provides a simple generic pool that uses channels instead of locks and supports both sync and async without dependence on any runtime.
Features
= []
The features below are related to logging errors, which should be unreachable.
log: Enables logging using thelogcrate.tracing: Enables logging using thetracingcrate.
Examples
Non-async example:
use Pool;
let mut pool = new;
pool.put;
pool.put;
let item1 = pool.try_get;
assert!;
let item2 = pool.blocking_get;
let none = pool.try_get;
assert!;
drop;
let item3 = pool.try_get;
assert!;
Async example:
use Pool;
block_on;
Safety
Instead of using an Option, this crate uses unsafe code ManuallyDrop in PooledItem.
And the only use of unsafe code ManuallyDrop::take() occurs when PooledItem is dropped.
License: MIT/Apache-2.0