ACE_MEM_SAP Class Reference

Defines the methods of shared memory management for shared memory transport. More...

#include <MEM_SAP.h>

Inheritance diagram for ACE_MEM_SAP:

Inheritance graph
[legend]
Collaboration diagram for ACE_MEM_SAP:

Collaboration graph
[legend]
List of all members.

Public Types

typedef ACE_Malloc_T< ACE_MMAP_MEMORY_POOL,
ACE_Process_Mutex, ACE_PI_Control_Block
MALLOC_TYPE
typedef ACE_MMAP_Memory_Pool_Options MALLOC_OPTIONS

Public Member Functions

virtual ~ACE_MEM_SAP (void)
 Destructor.

virtual int init (ACE_HANDLE handle, const ACE_TCHAR *name, MALLOC_OPTIONS *options)=0
virtual int fini ()
virtual ssize_t recv_buf (ACE_MEM_SAP_Node *&buf, int flags, const ACE_Time_Value *timeout)=0
virtual ssize_t send_buf (ACE_MEM_SAP_Node *buf, int flags, const ACE_Time_Value *timeout)=0
ACE_MEM_SAP_Nodeacquire_buffer (const ssize_t size)
int release_buffer (ACE_MEM_SAP_Node *buf)
void dump (void) const
 Dump the state of an object.


Public Attributes

 ACE_ALLOC_HOOK_DECLARE
 Declare the dynamic allocation hooks.


Protected Member Functions

int create_shm_malloc (const ACE_TCHAR *name, MALLOC_OPTIONS *options)
int close_shm_malloc (void)
 ACE_MEM_SAP (void)
 Constructor. Prevent this class from being instantiated.


Protected Attributes

ACE_HANDLE handle_
MALLOC_TYPEshm_malloc_
 Data exchange channel.


Detailed Description

Defines the methods of shared memory management for shared memory transport.

Definition at line 79 of file MEM_SAP.h.


Member Typedef Documentation

typedef ACE_MMAP_Memory_Pool_Options ACE_MEM_SAP::MALLOC_OPTIONS
 

Definition at line 85 of file MEM_SAP.h.

Referenced by create_shm_malloc(), and ACE_MEM_IO::init().

typedef ACE_Malloc_T<ACE_MMAP_MEMORY_POOL, ACE_Process_Mutex, ACE_PI_Control_Block> ACE_MEM_SAP::MALLOC_TYPE
 

Definition at line 84 of file MEM_SAP.h.

Referenced by create_shm_malloc(), and ACE_MT_MEM_IO::Simple_Queue::init().


Constructor & Destructor Documentation

ACE_MEM_SAP::~ACE_MEM_SAP void   )  [virtual]
 

Destructor.

Definition at line 39 of file MEM_SAP.cpp.

References shm_malloc_.

00040 {
00041   // ACE_TRACE ("ACE_MEM_SAP::~ACE_MEM_SAP");
00042   delete this->shm_malloc_;
00043 }

ACE_MEM_SAP::ACE_MEM_SAP void   )  [protected]
 

Constructor. Prevent this class from being instantiated.

Definition at line 32 of file MEM_SAP.cpp.

00033   : handle_ (ACE_INVALID_HANDLE),
00034     shm_malloc_ (0)
00035 {
00036   // ACE_TRACE ("ACE_MEM_SAP::ACE_MEM_SAP");
00037 }


Member Function Documentation

ACE_INLINE ACE_MEM_SAP_Node * ACE_MEM_SAP::acquire_buffer const ssize_t  size  ) 
 

request a buffer of size . Return 0 if the is not initialized.

Definition at line 37 of file MEM_SAP.inl.

References ACE_NEW_MALLOC_RETURN, ACE_TRACE, shm_malloc_, and ssize_t.

Referenced by ACE_MEM_IO::send().

00038 {
00039   ACE_TRACE ("ACE_MEM_SAP::acquire_buffer");
00040   if (this->shm_malloc_ == 0)
00041     return 0;                  // not initialized.
00042 
00043   ACE_MEM_SAP_Node *buf = 0;
00044 
00045   ACE_NEW_MALLOC_RETURN (buf,
00046                          static_cast<ACE_MEM_SAP_Node *>
00047                            (this->shm_malloc_->malloc (sizeof (ACE_MEM_SAP_Node) + size)),
00048                          ACE_MEM_SAP_Node (size),
00049                          0);
00050   return buf;
00051 }

int ACE_MEM_SAP::close_shm_malloc void   )  [protected]
 

Close down the share memory pool. Clean up the mmap file if we are the last one using it.

Definition at line 80 of file MEM_SAP.cpp.

References ACE_TRACE, ACE_Malloc_T<, ACE_LOCK, ACE_CB >::release(), and shm_malloc_.

Referenced by fini().

00081 {
00082   ACE_TRACE ("ACE_MEM_SAP::close_shm_malloc");
00083 
00084   int retv = -1;
00085 
00086   if (this->shm_malloc_ != 0)
00087     this->shm_malloc_->release (1);
00088 
00089   delete this->shm_malloc_;
00090   this->shm_malloc_ = 0;
00091 
00092   return retv;
00093 }

int ACE_MEM_SAP::create_shm_malloc const ACE_TCHAR name,
MALLOC_OPTIONS options
[protected]
 

Create a new shm_malloc object. Return 0 if succeed and -1 otherwise. This method should only be called from an acceptor class that wants to create a new memory pool for inter process communication.

Definition at line 54 of file MEM_SAP.cpp.

References ACE_NEW_RETURN, ACE_TCHAR, ACE_TRACE, ACE_Malloc_T<, ACE_LOCK, ACE_CB >::bad(), MALLOC_OPTIONS, MALLOC_TYPE, ACE_Malloc_T<, ACE_LOCK, ACE_CB >::remove(), and shm_malloc_.

Referenced by ACE_MT_MEM_IO::init(), and ACE_Reactive_MEM_IO::init().

00056 {
00057   ACE_TRACE ("ACE_MEM_SAP::create_shm_malloc");
00058 
00059   if (this->shm_malloc_ != 0)
00060     return -1;                  // already initialized.
00061 
00062   ACE_NEW_RETURN (this->shm_malloc_,
00063                   MALLOC_TYPE (name,
00064                                0,
00065                                options),
00066                   -1);
00067 
00068   if (this->shm_malloc_->bad () != 0)
00069     {
00070       this->shm_malloc_->remove (); // Cleanup OS resources
00071       delete this->shm_malloc_;
00072       this->shm_malloc_ = 0;
00073       return -1;
00074     }
00075 
00076   return 0;
00077 }

ACE_BEGIN_VERSIONED_NAMESPACE_DECL void ACE_MEM_SAP::dump void   )  const
 

Dump the state of an object.

Definition at line 18 of file MEM_SAP.cpp.

References ACE_BEGIN_DUMP, ACE_DEBUG, ACE_END_DUMP, ACE_LIB_TEXT, ACE_TRACE, ACE_Malloc_T<, ACE_LOCK, ACE_CB >::dump(), LM_DEBUG, and shm_malloc_.

00019 {
00020 #if defined (ACE_HAS_DUMP)
00021   ACE_TRACE ("ACE_MEM_SAP::dump");
00022 
00023   ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
00024   if (this->shm_malloc_ != 0)
00025     this->shm_malloc_->dump ();
00026   else
00027     ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("ACE_MEM_SAP uninitialized.\n")));
00028   ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
00029 #endif /* ACE_HAS_DUMP */
00030 }

int ACE_MEM_SAP::fini  )  [virtual]
 

Finalizing the MEM_SAP object. This method doesn't invoke the method.

Definition at line 46 of file MEM_SAP.cpp.

References ACE_TRACE, and close_shm_malloc().

Referenced by ACE_MEM_IO::fini().

00047 {
00048   ACE_TRACE ("ACE_MEM_SAP::fini");
00049 
00050   return this->close_shm_malloc ();
00051 }

virtual int ACE_MEM_SAP::init ACE_HANDLE  handle,
const ACE_TCHAR name,
MALLOC_OPTIONS options
[pure virtual]
 

Initialize the MEM_SAP object.

Implemented in ACE_Reactive_MEM_IO, and ACE_MT_MEM_IO.

Referenced by ACE_MEM_IO::init().

virtual ssize_t ACE_MEM_SAP::recv_buf ACE_MEM_SAP_Node *&  buf,
int  flags,
const ACE_Time_Value timeout
[pure virtual]
 

Fetch location of next available data into . As this operation read the address of the data off the socket using ACE::recv, timeout only applies to ACE::recv.

Implemented in ACE_Reactive_MEM_IO, and ACE_MT_MEM_IO.

Referenced by ACE_MEM_IO::fetch_recv_buf().

ACE_INLINE int ACE_MEM_SAP::release_buffer ACE_MEM_SAP_Node buf  ) 
 

release a buffer pointed by . Return -1 if the is not initialized.

Definition at line 54 of file MEM_SAP.inl.

References ACE_TRACE, ACE_Malloc_T<, ACE_LOCK, ACE_CB >::free(), and shm_malloc_.

Referenced by ACE_MEM_IO::fetch_recv_buf(), ACE_MT_MEM_IO::send_buf(), and ACE_Reactive_MEM_IO::send_buf().

00055 {
00056   ACE_TRACE ("ACE_MEM_SAP::release_buffer");
00057   if (this->shm_malloc_ == 0)
00058     return -1;                  // not initialized.
00059 
00060   this->shm_malloc_->free (buf);
00061   return 0;
00062 }

virtual ssize_t ACE_MEM_SAP::send_buf ACE_MEM_SAP_Node buf,
int  flags,
const ACE_Time_Value timeout
[pure virtual]
 

Wait to to amount of time to send . If times out a -1 is returned with <errno == ETIME>. If it succeeds the number of bytes sent is returned.

Implemented in ACE_Reactive_MEM_IO, and ACE_MT_MEM_IO.

Referenced by ACE_MEM_IO::send().


Member Data Documentation

ACE_MEM_SAP::ACE_ALLOC_HOOK_DECLARE
 

Declare the dynamic allocation hooks.

Definition at line 132 of file MEM_SAP.h.

ACE_HANDLE ACE_MEM_SAP::handle_ [protected]
 

Definition at line 150 of file MEM_SAP.h.

MALLOC_TYPE* ACE_MEM_SAP::shm_malloc_ [protected]
 

Data exchange channel.

Definition at line 153 of file MEM_SAP.h.

Referenced by acquire_buffer(), close_shm_malloc(), create_shm_malloc(), dump(), release_buffer(), and ~ACE_MEM_SAP().


The documentation for this class was generated from the following files:
Generated on Thu Nov 9 11:24:41 2006 for ACE by doxygen 1.3.6