diff options
author | William R. Otte <wotte@dre.vanderbilt.edu> | 2008-03-04 13:56:48 +0000 |
---|---|---|
committer | William R. Otte <wotte@dre.vanderbilt.edu> | 2008-03-04 13:56:48 +0000 |
commit | c4078c377d74290ebe4e66da0b4975da91732376 (patch) | |
tree | 1816ef391e42a07929304908ac0e21f4c2f6cb7b /ACE/examples/Shared_Memory/test_MM.cpp | |
parent | 700d1c1a6be348c6c70a2085e559baeb8f4a62ea (diff) | |
download | ATCD-c4078c377d74290ebe4e66da0b4975da91732376.tar.gz |
swap in externals for ACE and TAO
Diffstat (limited to 'ACE/examples/Shared_Memory/test_MM.cpp')
-rw-r--r-- | ACE/examples/Shared_Memory/test_MM.cpp | 74 |
1 files changed, 0 insertions, 74 deletions
diff --git a/ACE/examples/Shared_Memory/test_MM.cpp b/ACE/examples/Shared_Memory/test_MM.cpp deleted file mode 100644 index 2d98224f910..00000000000 --- a/ACE/examples/Shared_Memory/test_MM.cpp +++ /dev/null @@ -1,74 +0,0 @@ -// $Id$ - -#include "ace/Shared_Memory_MM.h" -#include "ace/Log_Msg.h" -#include "ace/OS_NS_errno.h" -#include "ace/OS_NS_unistd.h" -#include "ace/OS_NS_stdlib.h" - -ACE_RCSID(Shared_Memory, test_MM, "$Id$") - -#define SHMSZ 27 -ACE_TCHAR shm_key[] = ACE_TEXT ("/tmp/fooXXXXXX"); - -static void -client (void) -{ - ACE_Shared_Memory *shm_client = new ACE_Shared_Memory_MM (shm_key); - char *shm = (char *) shm_client->malloc (); - - for (char *s = shm; *s != '\0'; s++) - putchar (*s); - - putchar ('\n'); - *shm = '*'; -} - -static void -server (void) -{ - ACE_Shared_Memory *shm_server = new ACE_Shared_Memory_MM (shm_key, SHMSZ); - char *shm = (char *) shm_server->malloc (); - char *s = shm; - - for (char c = 'a'; c <= 'z'; c++) - *s++ = c; - - *s = '\0'; - - // Perform a busy wait (ugh) - while (*shm != '*') - ACE_OS::sleep (1); - - if (shm_server->remove () < 0) - ACE_ERROR ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("remove"))); - ACE_OS::unlink (shm_key); -} - -int -ACE_TMAIN (int, ACE_TCHAR *[]) -{ - if ( -#if defined (ACE_LACKS_MKSTEMP) - ACE_OS::mktemp (shm_key) == 0 -#else - ACE_OS::mkstemp (shm_key) == 0 -#endif - || (ACE_OS::unlink (shm_key) == -1 && errno == EPERM)) - ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p\n"), shm_key), 1); - - switch (ACE_OS::fork ()) - { - case -1: - ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("fork")), 1); - case 0: - // Make sure the server starts up first. - ACE_OS::sleep (1); - client (); - break; - default: - server (); - break; - } - return 0; -} |