IBAMR  IBAMR version 0.19.
Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Attributes | Static Private Attributes | List of all members
SAMRAI::tbox::ArenaManager Class Reference

#include <tbox/ArenaManager.h>

Public Member Functions

virtual Pointer< ArenagetFixedAllocator (const size_t bytes)
 
virtual Pointer< ArenagetScratchAllocator ()
 
virtual Pointer< ArenagetStandardAllocator ()
 
virtual void setFixedAllocator (const Pointer< FixedArena > &arena)
 
virtual void setScratchAllocator (const Pointer< Arena > &arena)
 
virtual void setStandardAllocator (const Pointer< Arena > &arena)
 

Static Public Member Functions

static ArenaManagergetManager ()
 
static void freeManager ()
 

Protected Member Functions

 ArenaManager ()
 
virtual ~ArenaManager ()
 
void registerSingletonSubclassInstance (ArenaManager *subclass_instance)
 

Private Attributes

Pointer< FixedArenad_fixed_allocator
 
Pointer< Arenad_scratch_allocator
 
Pointer< Arenad_standard_allocator
 

Static Private Attributes

static ArenaManagers_arena_instance
 
static bool s_registered_callback
 

Detailed Description

Class ArenaManager is a Singleton class that acts as an abstract factory for the arena memory management classes. It is a single point of control for memory allocation. Class ArenaManager supports three forms of memory management: standard allocators, scratch allocators, and fixed allocators. Standard memory allocators are the ones to be used in most cases; by default, the standard memory allocators use new and delete. The scratch allocators are for temporary scratch space. The fixed size memory allocators are arenas of a fixed size from which many memory requests will be made.

See the Design Patterns book by Gamma {et al.} for more information about the singleton pattern.

See also
tbox::Arena
tbox::FixedArena

Constructor & Destructor Documentation

◆ ArenaManager()

SAMRAI::tbox::ArenaManager::ArenaManager ( )
protected

The constructor for ArenaManager is protected. Consistent with the definition of a Singleton class, only subclasses have access to the constructor for the class.

◆ ~ArenaManager()

virtual SAMRAI::tbox::ArenaManager::~ArenaManager ( )
protectedvirtual

The destructor for ArenaManager is protected. See the comments for the constructor.

Member Function Documentation

◆ getManager()

static ArenaManager* SAMRAI::tbox::ArenaManager::getManager ( )
static

Return a pointer to the single instance of the memory arena manager. All access to the ArenaManager object is through getManager. For example, to get a pointer to the standard allocator arena, we must use ArenaManager::getManager()->getStandardAllocator().

Note that when the manager is accessed for the first time, the Singleton instance is registered with the ShutdownRegistry class which destroys such objects at program completion. Thus, users of this class do not explicitly allocate or deallocate the Singleton instance.

◆ freeManager()

static void SAMRAI::tbox::ArenaManager::freeManager ( )
static

Deallocate the ArenaManager instance. It is not necessary to call freeManager() at program termination, since it is automatically called by the ShutdownRegistry class.

◆ getFixedAllocator()

virtual Pointer<Arena> SAMRAI::tbox::ArenaManager::getFixedAllocator ( const size_t  bytes)
virtual

Allocate a fixed size arena of the given size. This arena may then be used in multiple memory allocation calls, although only one call to new will have been made.

◆ getScratchAllocator()

virtual Pointer<Arena> SAMRAI::tbox::ArenaManager::getScratchAllocator ( )
virtual

Return a pointer to scratch memory allocation arena. This arena is to be used for short-lived memory objects that should be allocated from a scratch space.

◆ getStandardAllocator()

virtual Pointer<Arena> SAMRAI::tbox::ArenaManager::getStandardAllocator ( )
virtual

Return a pointer to the standard memory allocation arena. Use this arena for most standard memory allocation needs.

◆ setFixedAllocator()

virtual void SAMRAI::tbox::ArenaManager::setFixedAllocator ( const Pointer< FixedArena > &  arena)
virtual

Define a new fixed memory arena allocator.

◆ setScratchAllocator()

virtual void SAMRAI::tbox::ArenaManager::setScratchAllocator ( const Pointer< Arena > &  arena)
virtual

Define a new scratch memory arena allocator.

◆ setStandardAllocator()

virtual void SAMRAI::tbox::ArenaManager::setStandardAllocator ( const Pointer< Arena > &  arena)
virtual

Define a new standard memory arena allocator.

◆ registerSingletonSubclassInstance()

void SAMRAI::tbox::ArenaManager::registerSingletonSubclassInstance ( ArenaManager subclass_instance)
protected

Initialize Singleton instance with instance of subclass. This function is used to make the singleton object unique when inheriting from this base class.

Member Data Documentation

◆ s_arena_instance

ArenaManager* SAMRAI::tbox::ArenaManager::s_arena_instance
staticprivate

◆ s_registered_callback

bool SAMRAI::tbox::ArenaManager::s_registered_callback
staticprivate

◆ d_fixed_allocator

Pointer<FixedArena> SAMRAI::tbox::ArenaManager::d_fixed_allocator
private

◆ d_scratch_allocator

Pointer<Arena> SAMRAI::tbox::ArenaManager::d_scratch_allocator
private

◆ d_standard_allocator

Pointer<Arena> SAMRAI::tbox::ArenaManager::d_standard_allocator
private

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