3 #include "ace/MMAP_Memory_Pool.h"
4 #include "ace/Local_Memory_Pool.h"
6 #ifndef ACE_LACKS_SYSV_SHMEM
7 # include "ace/Shared_Memory_Pool.h"
8 #endif /* !ACE_LACKS_SYSV_SHMEM */
10 #ifndef ACE_LACKS_SBRK
11 # include "ace/Sbrk_Memory_Pool.h"
12 #endif /* !ACE_LACKS_SBRK */
14 #include "ace/Process_Mutex.h"
15 #include "ace/Malloc_T.h"
18 // Strategic typedefs for memory allocation.
20 typedef ACE_Malloc
<ACE_LOCAL_MEMORY_POOL
, ACE_SYNCH_MUTEX
> L_ALLOCATOR
;
21 typedef ACE_Malloc
<ACE_MMAP_MEMORY_POOL
, ACE_Process_Mutex
> M_ALLOCATOR
;
23 #if defined (ACE_LACKS_SYSV_SHMEM)
24 typedef ACE_Malloc
<ACE_MMAP_MEMORY_POOL
, ACE_SYNCH_MUTEX
> SP_ALLOCATOR
;
25 typedef ACE_Malloc
<ACE_MMAP_MEMORY_POOL
, ACE_SYNCH_MUTEX
> ST_ALLOCATOR
;
27 typedef ACE_Malloc
<ACE_SHARED_MEMORY_POOL
, ACE_Process_Mutex
> SP_ALLOCATOR
;
28 typedef ACE_Malloc
<ACE_SHARED_MEMORY_POOL
, ACE_SYNCH_MUTEX
> ST_ALLOCATOR
;
29 #endif /* ACE_LACKS_SYSV_SHMEM */
31 #if defined (ACE_LACKS_SBRK)
32 typedef ACE_Malloc
<ACE_LOCAL_MEMORY_POOL
, ACE_SYNCH_MUTEX
> SB_ALLOCATOR
;
34 typedef ACE_Malloc
<ACE_SBRK_MEMORY_POOL
, ACE_SYNCH_MUTEX
> SB_ALLOCATOR
;
35 #endif /* ACE_LACKS_SBRK */
38 ACE_Allocator
*Malloc::instance_
= 0;
40 // This is a factory that decides what type of allocator to create.
45 if (Malloc::instance_
== 0)
47 if (Options::instance ()->child ())
48 Malloc::instance_
= new ACE_Allocator_Adapter
<M_ALLOCATOR
>;
49 else if (Options::instance ()->spawn_threads ())
51 if (Options::instance ()->use_sbrk ())
52 Malloc::instance_
= new ACE_Allocator_Adapter
<SB_ALLOCATOR
>;
53 else if (Options::instance ()->use_shmem ())
54 Malloc::instance_
= new ACE_Allocator_Adapter
<ST_ALLOCATOR
>;
56 Malloc::instance_
= new ACE_Allocator_Adapter
<L_ALLOCATOR
>;
58 else if (Options::instance ()->use_mmap ())
59 Malloc::instance_
= new ACE_Allocator_Adapter
<M_ALLOCATOR
>;
60 else // Use Shared_Memory_Pool.
61 Malloc::instance_
= new ACE_Allocator_Adapter
<SP_ALLOCATOR
>;
64 return Malloc::instance_
;