12#ifndef ROC_CORE_ALLOCATION_POLICY_H_
13#define ROC_CORE_ALLOCATION_POLICY_H_
31 template <
class T>
void destroy(T&
object) {
32 arena_->destroy_object(
object);
54 template <
class T>
void destroy(T&
object) {
55 pool_->destroy_object(
object);
70 typedef void (*DestroyFunc)(
void*);
76 : destroy_func_((DestroyFunc)destroy_func) {
78 roc_panic(
"allocation policy: null function");
83 template <
class T>
void destroy(T&
object) {
84 destroy_func_(&
object);
88 DestroyFunc destroy_func_;
ArenaAllocation(IArena &arena)
Initialize.
void destroy(T &object)
Destroy object and return memory to arena.
IArena & arena() const
Get arena.
CustomAllocation(void(*destroy_func)(T *))
Initialize.
void destroy(T &object)
Invoke custom destruction function.
Allocation policy for objects that does not have automatic deallocation.
void destroy(T &)
No-op. When SharedPtr or ScopedPtr "destroys" object, nothing happens. The user is responsible for de...
PoolAllocation(IPool &pool)
Initialize.
IPool & pool() const
Get pool.
void destroy(T &object)
Destroy object and return memory to pool.
General-purpose building blocks and platform abstraction layer.
#define roc_panic(...)
Print error message and terminate program gracefully.