Expand description
Anchored Pool
Provides bounded and unbounded pools for any type of resource, as well as pools specific to
Vec<u8> buffers.
The resource pools can have a user-chosen init_resource function run to create a new resource,
and whenever a resource is returned to the pool, a reset_resource callback is first run.
The buffer pools use these features to create new empty Vec<u8> buffers as resources, and
whenever a buffer is returned to the pool, the buffer is either cleared (without changing its
capacity) if its capacity is at most a user-chosen max_buffer_capacity, and is otherwise replaced
with a new empty Vec<u8>.
§Features
kanal(default): Implement shared (threadsafe) pools usingkanalchannels.crossbeam-channel: Unless thekanalfeature is enabled, implement shared (threadsafe) pools usingcrossbeam-channelchannels.clone-behavior: Implementsclone-behaviortraits for relevant structs.
If neither of the kanal or crossbeam-channel features is enabled, a compile-time error
is thrown.
§License
Licensed under either of
- Apache License, Version 2.0 (LICENSE-APACHE)
- MIT license (LICENSE-MIT)
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this crate by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
Structs§
- Bounded
Buffer Pool - A pool with a fixed number of
Vec<u8>buffers. - Bounded
Pool - A resource pool with a fixed number of
Resources. - OutOf
Buffers - An error that may, instead of waiting for a buffer to become available, be returned if no buffers were available in a bounded pool.
- Pooled
Buffer - A handle to a buffer in a pool, which returns the buffer back to the pool when dropped.
- Pooled
Resource - A handle to
Resourcein a pool, which returns theResourceback to the pool when dropped. - Reset
Buffer - An implementation of
ResetResource<Vec<u8>>. - Reset
Nothing - Implements
ResetResourcewith a no-op. Can be used when aResourcedoes not need to be reset when it is returned to a pool. - Resource
Pool Empty - An error that may, instead of waiting for a
Resourceto become available, be returned if noResources were available in a bounded pool. - Shared
Bounded Buffer Pool - A threadsafe pool with a fixed number of
Vec<u8>buffers. - Shared
Bounded Pool - A threadsafe resource pool with a fixed number of
Resources. - Shared
Unbounded Buffer Pool - A threadsafe pool with a growable number of
Vec<u8>buffers. - Shared
Unbounded Pool - A threadsafe resource pool with a growable number of
Resources. - Unbounded
Buffer Pool - A pool with a growable number of
Vec<u8>buffers. - Unbounded
Pool - A resource pool with a growable number of
Resources.
Traits§
- Reset
Resource - Trait for the operation performed when a
Resourceis returned to a pool.