18 #ifndef ION_BASE_ALLOCATIONMANAGER_H_
19 #define ION_BASE_ALLOCATIONMANAGER_H_
21 #include "base/macros.h"
36 GetInstance()->default_allocation_lifetime_ = lifetime;
39 return GetInstance()->default_allocation_lifetime_;
59 mgr->default_allocators_[lifetime] =
60 allocator.
Get() ? allocator : mgr->malloc_allocator_;
64 return GetInstance()->default_allocators_[lifetime];
72 return mgr->default_allocators_[mgr->default_allocation_lifetime_];
78 return GetInstance()->malloc_allocator_;
86 return allocator.
Get() ? allocator : GetDefaultAllocator();
92 class MallocAllocator;
104 AllocatorPtr default_allocators_[kNumAllocationLifetimes];
115 #endif // ION_BASE_ALLOCATIONMANAGER_H_
AllocationLifetime
All memory allocated within Ion uses an Allocator chosen based on the predicted lifetime of the targe...
AllocationManager is a singleton class that is used to manage Allocators used to allocate Ion objects...
static const AllocatorPtr & GetDefaultAllocator()
Convenience function that returns the default allocator to use when no lifetime is specified...
T * Get() const
Returns a raw pointer to the instance, which may be NULL.
static const AllocatorPtr & GetNonNullAllocator(const AllocatorPtr &allocator)
This convenience function can be used where a non-NULL Allocator pointer is needed.
static void SetDefaultAllocatorForLifetime(AllocationLifetime lifetime, const AllocatorPtr &allocator)
Sets/returns the default Allocator to use for a specific AllocationLifetime.
static const AllocatorPtr & GetMallocAllocator()
Returns an allocator that performs conventional allocation and deallocation with malloc() and free()...
static AllocationLifetime GetDefaultAllocationLifetime()
static void SetDefaultAllocationLifetime(AllocationLifetime lifetime)
Sets/returns the AllocationLifetime that is assumed when a default new() operator is used for an Allo...
static const AllocatorPtr & GetDefaultAllocatorForLifetime(AllocationLifetime lifetime)