roopes_core/patterns/heap_pool/
mod.rs

1//!
2#![cfg_attr(feature = "doc-images",
3  cfg_attr(
4    all(),
5    doc = ::embed_doc_image::embed_image!(
6        "heap-pool-diagram",
7        "src/patterns/heap_pool/heap_pool.svg"
8)))]
9//! Contains types which allow client code to
10//! generate, use, and re-use heap-allocated
11//! objects efficiently.
12//!
13//! ![heap pool diagram][heap-pool-diagram]
14
15pub mod refcell_box;
16
17#[cfg(test)]
18mod tests;
19
20/// Holds a list of allocated objects in a
21/// scalable pool.  Previously allocated
22/// objects can be checked back in after use, to
23/// prevent immediate deallocation.
24pub trait HeapPool<C>
25{
26    /// Get a value from the [`HeapPool`].
27    fn check_out(&mut self) -> C;
28
29    /// Give a value back to the [`HeapPool`].
30    fn check_in(
31        &mut self,
32        container: C,
33    );
34}
35
36/// Exposes the [`HeapPool`] types at the library
37/// level.
38pub mod prelude
39{
40    pub use super::HeapPool;
41}