SPH
Public Member Functions | List of all members
FallbackAllocator< TPrimary, TFallback > Class Template Reference

Allocator that attemps to allocate using given primary allocator, and if the allocation fails, it allocates using a second fallback allocator. More...

#include <Allocators.h>

Inheritance diagram for FallbackAllocator< TPrimary, TFallback >:

Public Member Functions

INLINE MemoryBlock allocate (const std::size_t size, const std::size_t align) noexcept
 
INLINE void deallocate (MemoryBlock &block) noexcept
 
INLINE const TPrimary & primary () const
 
INLINE const TFallback & fallback () const
 

Detailed Description

template<typename TPrimary, typename TFallback>
class FallbackAllocator< TPrimary, TFallback >

Allocator that attemps to allocate using given primary allocator, and if the allocation fails, it allocates using a second fallback allocator.

Note that this is just a simple compositor and it doesn't guarantee that the fallback allocation succeeds. To ensure the allocation is successful, consider nesting multiple fallback allocators together and provide an allocator that cannot fail as the last one.

Definition at line 101 of file Allocators.h.

Member Function Documentation

◆ allocate()

template<typename TPrimary , typename TFallback >
INLINE MemoryBlock FallbackAllocator< TPrimary, TFallback >::allocate ( const std::size_t  size,
const std::size_t  align 
)
inlinenoexcept

Definition at line 103 of file Allocators.h.

◆ deallocate()

template<typename TPrimary , typename TFallback >
INLINE void FallbackAllocator< TPrimary, TFallback >::deallocate ( MemoryBlock block)
inlinenoexcept

Definition at line 112 of file Allocators.h.

◆ fallback()

template<typename TPrimary , typename TFallback >
INLINE const TFallback& FallbackAllocator< TPrimary, TFallback >::fallback ( ) const
inline

Definition at line 124 of file Allocators.h.

◆ primary()

template<typename TPrimary , typename TFallback >
INLINE const TPrimary& FallbackAllocator< TPrimary, TFallback >::primary ( ) const
inline

Definition at line 120 of file Allocators.h.


The documentation for this class was generated from the following file: