Skip to main content

RawPoolable

Trait RawPoolable 

Source
pub unsafe trait RawPoolable: Sized {
    // Required methods
    fn empty(pool: WeakPool<Self>) -> Self;
    fn reset(&mut self);
    fn capacity(&self) -> usize;
    fn really_drop(self);
}
Expand description

Low level global pool trait for maximum control

Implementing this trait allows full low level control over where the pool pointer is stored. For example if you are pooling an allocated data structure, you could store the pool pointer in the allocation to keep the size of the handle struct to a minimum. E.G. you’re pooling a triomphe::ThinArc. Or, if you have a static global pool, then you would not need to keep a pool pointer at all.

The object’s drop implementation should return the object to the pool instead of deallocating it

Implementing this trait correctly is extremely tricky, and requires unsafe code, therefore it is marked as unsafe.

Most of the time you should use the GPooled wrapper.

Required Methods§

Source

fn empty(pool: WeakPool<Self>) -> Self

allocate a new empty object and set it’s pool pointer to pool

Source

fn reset(&mut self)

empty the collection and reset it to its default state so it can be put back in the pool

Source

fn capacity(&self) -> usize

return the capacity of the collection

Source

fn really_drop(self)

Actually drop the inner object, don’t put it back in the pool, make sure you do not call both this method and the drop implementation that puts the object back in the pool!

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§