diff options
author | levine <levine@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1997-10-02 03:41:07 +0000 |
---|---|---|
committer | levine <levine@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1997-10-02 03:41:07 +0000 |
commit | 2af03a67c280d3ef941e8506fb1c34f4d1fbe412 (patch) | |
tree | f17373f064fd52c30fa649984e2dbc42ca51b7cb /tests/SV_Shared_Memory_Test.cpp | |
parent | e4902ac75185e9337b4ec6588627171d0076347d (diff) | |
download | ATCD-2af03a67c280d3ef941e8506fb1c34f4d1fbe412.tar.gz |
delay construction of allocator until first needed because it needs something that the ACE_Object_Manager constructs
Diffstat (limited to 'tests/SV_Shared_Memory_Test.cpp')
-rw-r--r-- | tests/SV_Shared_Memory_Test.cpp | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/tests/SV_Shared_Memory_Test.cpp b/tests/SV_Shared_Memory_Test.cpp index afecca13a22..f178d793f34 100644 --- a/tests/SV_Shared_Memory_Test.cpp +++ b/tests/SV_Shared_Memory_Test.cpp @@ -23,8 +23,16 @@ #if defined (ACE_HAS_SYSV_IPC) // Shared memory allocator (note that this chews up the -// ACE_DEFAULT_SEM_KEY). -static ACE_Malloc<ACE_SHARED_MEMORY_POOL, ACE_SV_Semaphore_Simple> allocator; +// ACE_DEFAULT_SEM_KEY). Hide the allocator inside this function so +// that it doesn't get constructed until after the ACE_Object_Manager +// gets constructed, even with ACE_HAS_NONSTATIC_OBJECT_MANAGER. +static +ACE_Malloc<ACE_SHARED_MEMORY_POOL, ACE_SV_Semaphore_Simple> & +allocator () +{ + static ACE_Malloc<ACE_SHARED_MEMORY_POOL, ACE_SV_Semaphore_Simple> allocator; + return allocator; +} const int SEM_KEY_1 = ACE_DEFAULT_SEM_KEY + 1; const int SEM_KEY_2 = ACE_DEFAULT_SEM_KEY + 2; @@ -38,11 +46,11 @@ parent (char *shm) ACE_SV_Semaphore_Complex mutex; ACE_ASSERT (mutex.open (SEM_KEY_1, - ACE_SV_Semaphore_Complex::ACE_CREATE, 0) != -1); + ACE_SV_Semaphore_Complex::ACE_CREATE, 0) != -1); ACE_SV_Semaphore_Complex synch; ACE_ASSERT (synch.open (SEM_KEY_2, - ACE_SV_Semaphore_Complex::ACE_CREATE, 0) != -1); + ACE_SV_Semaphore_Complex::ACE_CREATE, 0) != -1); for (int i = 0; i < SHMSZ; i++) shm[i] = SHMDATA[i]; @@ -52,7 +60,7 @@ parent (char *shm) else if (synch.acquire () == -1) ACE_ERROR ((LM_ERROR, "(%P) %p", "parent synch.acquire")); - if (allocator.remove () == -1) + if (allocator ().remove () == -1) ACE_ERROR ((LM_ERROR, "(%P) %p\n", "parent allocator.remove")); if (mutex.remove () == -1) ACE_ERROR ((LM_ERROR, "(%P) %p\n", "parent mutex.remove")); @@ -66,12 +74,12 @@ child (char *shm) { ACE_SV_Semaphore_Complex mutex; ACE_ASSERT (mutex.open (SEM_KEY_1, - ACE_SV_Semaphore_Complex::ACE_CREATE, 0) != -1); + ACE_SV_Semaphore_Complex::ACE_CREATE, 0) != -1); ACE_SV_Semaphore_Complex synch; ACE_ASSERT (synch.open (SEM_KEY_2, - ACE_SV_Semaphore_Complex::ACE_CREATE, 0) != -1); + ACE_SV_Semaphore_Complex::ACE_CREATE, 0) != -1); while (mutex.tryacquire () == -1) if (errno == EAGAIN) @@ -108,7 +116,7 @@ main (int, char *[]) ACE_START_TEST ("SV_Shared_Memory_Test"); #if defined (ACE_HAS_SYSV_IPC) - char *shm = (char *) allocator.malloc (27); + char *shm = (char *) allocator ().malloc (27); switch (ACE_OS::fork ("SV_Shared_Memory_Test.cpp")) // switch (1) @@ -125,7 +133,7 @@ main (int, char *[]) } #else ACE_ERROR ((LM_ERROR, - "SYSV IPC is not supported on this platform\n")); + "SYSV IPC is not supported on this platform\n")); #endif /* ACE_HAS_SYSV_IPC */ ACE_END_TEST; return 0; |