// $Id$ #include "Options.h" #include "Malloc.h" #include "ace/Process_Mutex.h" ACE_RCSID(Shared_Malloc, Malloc, "$Id$") // 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_; } #if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) template class ACE_Allocator_Adapter; #if !defined (ACE_LACKS_SBRK) template class ACE_Allocator_Adapter; template class ACE_Malloc ; template class ACE_Malloc_T ; #endif /* ! ACE_LACKS_SBRK */ #if !defined (ACE_LACKS_SYSV_SHMEM) template class ACE_Allocator_Adapter; template class ACE_Allocator_Adapter; #endif /* ! ACE_LACKS_SYSV_SHMEM */ template class ACE_Malloc ; template class ACE_Malloc_T ; #if !defined (ACE_HAS_THREADS) && !defined(ACE_HAS_STD_TEMPLATE_SPECIALIZATION) template class ACE_Read_Guard; template class ACE_Write_Guard; #endif /* ! ACE_HAS_THREADS && ! ACE_HAS_STD_TEMPLATE_SPECIALIZATION */ #if defined (ACE_LACKS_SYSV_SHMEM) #else template class ACE_Malloc ; template class ACE_Malloc ; template class ACE_Malloc_T ; template class ACE_Malloc_T ; #endif /* ACE_LACKS_SYSV_SHMEM */ #elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) #pragma instantiate ACE_Allocator_Adapter #pragma instantiate ACE_Allocator_Adapter #if !defined (ACE_LACKS_SBRK) #pragma instantiate ACE_Allocator_Adapter #pragma instantiate ACE_Malloc #pragma instantiate ACE_Malloc_T #endif /* ! ACE_LACKS_SYSV_SHMEM */ #if !defined (ACE_LACKS_SBRK) #pragma instantiate ACE_Allocator_Adapter #endif /* ! ACE_LACKS_SYSV_SHMEM */ #pragma instantiate ACE_Allocator_Adapter #pragma instantiate ACE_Malloc #pragma instantiate ACE_Malloc #pragma instantiate ACE_Malloc_T #pragma instantiate ACE_Malloc_T #pragma instantiate ACE_Read_Guard #pragma instantiate ACE_Write_Guard #if !defined (ACE_HAS_THREADS) #pragma instantiate ACE_Read_Guard #pragma instantiate ACE_Write_Guard #endif /* ! ACE_HAS_THREADS */ #if defined (ACE_LACKS_SYSV_SHMEM) #pragma instantiate ACE_Malloc #pragma instantiate ACE_Malloc_T #else #pragma instantiate ACE_Malloc #pragma instantiate ACE_Malloc #pragma instantiate ACE_Malloc_T #pragma instantiate ACE_Malloc_T #endif /* ACE_LACKS_SYSV_SHMEM */ #endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */