#include "Options.h" #include "Malloc.h" #include "ace/MMAP_Memory_Pool.h" #include "ace/Local_Memory_Pool.h" #ifndef ACE_LACKS_SYSV_SHMEM # include "ace/Shared_Memory_Pool.h" #endif /* !ACE_LACKS_SYSV_SHMEM */ #ifndef ACE_LACKS_SBRK # include "ace/Sbrk_Memory_Pool.h" #endif /* !ACE_LACKS_SBRK */ #include "ace/Process_Mutex.h" #include "ace/Malloc_T.h" // Strategic typedefs for memory allocation. typedef ACE_Malloc L_ALLOCATOR; typedef ACE_Malloc M_ALLOCATOR; #if defined (ACE_LACKS_SYSV_SHMEM) typedef ACE_Malloc SP_ALLOCATOR; typedef ACE_Malloc ST_ALLOCATOR; #else typedef ACE_Malloc SP_ALLOCATOR; typedef ACE_Malloc ST_ALLOCATOR; #endif /* ACE_LACKS_SYSV_SHMEM */ #if defined (ACE_LACKS_SBRK) typedef ACE_Malloc SB_ALLOCATOR; #else typedef ACE_Malloc SB_ALLOCATOR; #endif /* ACE_LACKS_SBRK */ // Singleton ACE_Allocator *Malloc::instance_ = 0; // This is a factory that decides what type of allocator to create. ACE_Allocator * Malloc::instance (void) { if (Malloc::instance_ == 0) { if (Options::instance ()->child ()) Malloc::instance_ = new ACE_Allocator_Adapter; else if (Options::instance ()->spawn_threads ()) { if (Options::instance ()->use_sbrk ()) Malloc::instance_ = new ACE_Allocator_Adapter; else if (Options::instance ()->use_shmem ()) Malloc::instance_ = new ACE_Allocator_Adapter; else Malloc::instance_ = new ACE_Allocator_Adapter; } else if (Options::instance ()->use_mmap ()) Malloc::instance_ = new ACE_Allocator_Adapter; else // Use Shared_Memory_Pool. Malloc::instance_ = new ACE_Allocator_Adapter; } return Malloc::instance_; }