1 // $Id: SV_Shared_Memory.cpp 80826 2008-03-04 14:51:23Z wotte $
3 #include "ace/SV_Shared_Memory.h"
4 #include "ace/Log_Msg.h"
6 #if !defined (__ACE_INLINE__)
7 #include "ace/SV_Shared_Memory.inl"
8 #endif /* __ACE_INLINE__ */
10 ACE_RCSID(ace
, SV_Shared_Memory
, "$Id: SV_Shared_Memory.cpp 80826 2008-03-04 14:51:23Z wotte $")
12 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
14 ACE_ALLOC_HOOK_DEFINE(ACE_SV_Shared_Memory
)
17 ACE_SV_Shared_Memory::dump (void) const
19 #if defined (ACE_HAS_DUMP)
20 ACE_TRACE ("ACE_SV_Shared_Memory::dump");
21 #endif /* ACE_HAS_DUMP */
24 // Creates a shared memory segment of SIZE bytes and *does* attach to
28 ACE_SV_Shared_Memory::open_and_attach (key_t external_id
,
35 ACE_TRACE ("ACE_SV_Shared_Memory::open_and_attach");
36 if (this->open (external_id
, sz
, create
, perms
) == -1)
38 else if (this->attach (virtual_addr
, flags
) == -1)
44 // Constructor interface to this->open_and_attach () member function.
46 ACE_SV_Shared_Memory::ACE_SV_Shared_Memory (key_t external_id
,
53 ACE_TRACE ("ACE_SV_Shared_Memory::ACE_SV_Shared_Memory");
54 if (this->open_and_attach (external_id
, sz
, create
,
55 perms
, virtual_addr
, flags
) == -1)
56 ACE_ERROR ((LM_ERROR
, ACE_TEXT ("%p\n"),
57 ACE_TEXT ("ACE_SV_Shared_Memory::ACE_SV_Shared_Memory")));
60 // The "do nothing" constructor.
62 ACE_SV_Shared_Memory::ACE_SV_Shared_Memory (void)
67 ACE_TRACE ("ACE_SV_Shared_Memory::ACE_SV_Shared_Memory");
70 // Added this constructor to accept an internal id, the one generated
71 // when a server constructs with the key IPC_PRIVATE. The client can
72 // be passed ACE_SV_Shared_Memory::internal_id via a socket and call
73 // this construtor to attach the existing segment. This prevents
74 // having to hard-code a key in advance. Courtesy of Marvin Wolfthal
77 ACE_SV_Shared_Memory::ACE_SV_Shared_Memory (ACE_HANDLE int_id
,
79 : internal_id_ (int_id
),
82 ACE_TRACE ("ACE_SV_Shared_Memory::ACE_SV_Shared_Memory");
83 if (this->attach (0, flags
) == -1)
84 ACE_ERROR ((LM_ERROR
, ACE_TEXT ("%p\n"),
85 ACE_TEXT ("ACE_SV_Shared_Memory::ACE_SV_Shared_Memory")));
88 ACE_END_VERSIONED_NAMESPACE_DECL