Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

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 Methods

virtual ~ACE_MEM_SAP (void)
 Destructor. More...

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)
 request a buffer of size <size>. Return 0 if the <shm_malloc_> is not initialized. More...

int release_buffer (ACE_MEM_SAP_Node *buf)
 release a buffer pointed by <buf>. Return -1 if the <shm_malloc_> is not initialized. More...

void dump (void) const
 Dump the state of an object. More...


Public Attributes

 ACE_ALLOC_HOOK_DECLARE
 Declare the dynamic allocation hooks. More...


Protected Methods

int create_shm_malloc (const ACE_TCHAR *name, MALLOC_OPTIONS *options)
int close_shm_malloc (void)
 Close down the share memory pool. Clean up the mmap file if we are the last one using it. More...

 ACE_MEM_SAP (void)
 Constructor. Prevent this class from being instantiated. More...


Protected Attributes

ACE_HANDLE handle_
MALLOC_TYPEshm_malloc_
 Data exchange channel. More...


Detailed Description

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

Definition at line 74 of file MEM_SAP.h.


Member Typedef Documentation

typedef ACE_MMAP_Memory_Pool_Options ACE_MEM_SAP::MALLOC_OPTIONS
 

Definition at line 80 of file MEM_SAP.h.

Referenced by 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 79 of file MEM_SAP.h.

Referenced by ACE_MT_MEM_IO::Simple_Queue::init.


Constructor & Destructor Documentation

ASYS_INLINE ACE_MEM_SAP::~ACE_MEM_SAP void    [virtual]
 

Destructor.

Definition at line 34 of file MEM_SAP.i.

References shm_malloc_.

00035 {
00036   // ACE_TRACE ("ACE_MEM_SAP::~ACE_MEM_SAP");
00037   delete this->shm_malloc_;
00038 }

ACE_MEM_SAP::ACE_MEM_SAP void    [protected]
 

Constructor. Prevent this class from being instantiated.

Definition at line 29 of file MEM_SAP.cpp.

00030   : handle_ (ACE_INVALID_HANDLE),
00031     shm_malloc_ (0)
00032 {
00033   // ACE_TRACE ("ACE_MEM_SAP::ACE_MEM_SAP");
00034 }


Member Function Documentation

ASYS_INLINE ACE_MEM_SAP_Node * ACE_MEM_SAP::acquire_buffer const ssize_t    size
 

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

Definition at line 42 of file MEM_SAP.i.

References ACE_NEW_MALLOC_RETURN, ACE_TRACE, shm_malloc_, and ssize_t.

Referenced by ACE_MEM_IO::send.

00043 {
00044   ACE_TRACE ("ACE_MEM_SAP::acquire_buffer");
00045   if (this->shm_malloc_ == 0)
00046     return 0;                  // not initialized.
00047 
00048   ACE_MEM_SAP_Node *buf = 0;
00049 
00050   ACE_NEW_MALLOC_RETURN (buf,
00051                          ACE_static_cast (ACE_MEM_SAP_Node *,
00052                            this->shm_malloc_->malloc (sizeof (ACE_MEM_SAP_Node) + size)),
00053                          ACE_MEM_SAP_Node (size),
00054                          0);
00055   return buf;
00056 }

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 71 of file MEM_SAP.cpp.

References ACE_TRACE, ACE_Malloc_T< ACE_MMAP_MEMORY_POOL, ACE_Process_Mutex, ACE_PI_Control_Block >::release, and shm_malloc_.

Referenced by fini.

00072 {
00073   ACE_TRACE ("ACE_MEM_SAP::close_shm_malloc");
00074 
00075   int retv = -1;
00076 
00077   if (this->shm_malloc_ != 0)
00078     this->shm_malloc_->release (1);
00079 
00080   delete this->shm_malloc_;
00081   this->shm_malloc_ = 0;
00082 
00083   return retv;
00084 }

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 45 of file MEM_SAP.cpp.

References ACE_NEW_RETURN, ACE_TCHAR, ACE_TRACE, ACE_Malloc_T< ACE_MMAP_MEMORY_POOL, ACE_Process_Mutex, ACE_PI_Control_Block >::bad, ACE_Malloc_T< ACE_MMAP_MEMORY_POOL, ACE_Process_Mutex, ACE_PI_Control_Block >::remove, and shm_malloc_.

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

00047 {
00048   ACE_TRACE ("ACE_MEM_SAP::create_shm_malloc");
00049 
00050   if (this->shm_malloc_ != 0)
00051     return -1;                  // already initialized.
00052 
00053   ACE_NEW_RETURN (this->shm_malloc_,
00054                   MALLOC_TYPE (name,
00055                                0,
00056                                options),
00057                   -1);
00058 
00059   if (this->shm_malloc_->bad () != 0)
00060     {
00061       this->shm_malloc_->remove (); // Cleanup OS resources
00062       delete this->shm_malloc_;
00063       this->shm_malloc_ = 0;
00064       return -1;
00065     }
00066 
00067   return 0;
00068 }

void ACE_MEM_SAP::dump void    const
 

Dump the state of an object.

Definition at line 17 of file MEM_SAP.cpp.

References ACE_BEGIN_DUMP, ACE_DEBUG, ACE_END_DUMP, ACE_LIB_TEXT, ACE_TRACE, ACE_Malloc_T< ACE_MMAP_MEMORY_POOL, ACE_Process_Mutex, ACE_PI_Control_Block >::dump, LM_DEBUG, and shm_malloc_.

00018 {
00019   ACE_TRACE ("ACE_MEM_SAP::dump");
00020 
00021   ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
00022   if (this->shm_malloc_ != 0)
00023     this->shm_malloc_->dump ();
00024   else
00025     ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("ACE_MEM_SAP uninitialized.\n")));
00026   ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
00027 }

int ACE_MEM_SAP::fini   [virtual]
 

Finalizing the MEM_SAP object. This method doesn't invoke the <remove> method.

Definition at line 37 of file MEM_SAP.cpp.

References ACE_TRACE, and close_shm_malloc.

Referenced by ACE_MEM_IO::fini.

00038 {
00039   ACE_TRACE ("ACE_MEM_SAP::fini");
00040 
00041   return this->close_shm_malloc ();
00042 }

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.

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 <recv_buffer_>. 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.

Referenced by ACE_MEM_IO::fetch_recv_buf.

ASYS_INLINE int ACE_MEM_SAP::release_buffer ACE_MEM_SAP_Node   buf
 

release a buffer pointed by <buf>. Return -1 if the <shm_malloc_> is not initialized.

Definition at line 59 of file MEM_SAP.i.

References ACE_TRACE, ACE_Malloc_T< ACE_MMAP_MEMORY_POOL, ACE_Process_Mutex, ACE_PI_Control_Block >::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.

00060 {
00061   ACE_TRACE ("ACE_MEM_SAP::release_buffer");
00062   if (this->shm_malloc_ == 0)
00063     return -1;                  // not initialized.
00064 
00065   this->shm_malloc_->free (buf);
00066   return 0;
00067 }

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 <timeout> amount of time to send <buf>. If <send> 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.

Referenced by ACE_MEM_IO::send.


Member Data Documentation

ACE_MEM_SAP::ACE_ALLOC_HOOK_DECLARE
 

Declare the dynamic allocation hooks.

Definition at line 127 of file MEM_SAP.h.

ACE_HANDLE ACE_MEM_SAP::handle_ [protected]
 

Definition at line 145 of file MEM_SAP.h.

Referenced by ACE_Reactive_MEM_IO::init, ACE_Reactive_MEM_IO::recv_buf, and ACE_Reactive_MEM_IO::send_buf.

MALLOC_TYPE* ACE_MEM_SAP::shm_malloc_ [protected]
 

Data exchange channel.

Definition at line 148 of file MEM_SAP.h.

Referenced by acquire_buffer, close_shm_malloc, create_shm_malloc, dump, ACE_Reactive_MEM_IO::get_buf_len, ACE_MT_MEM_IO::init, ACE_MT_MEM_IO::recv_buf, ACE_Reactive_MEM_IO::recv_buf, release_buffer, ACE_MT_MEM_IO::send_buf, ACE_Reactive_MEM_IO::send_buf, and ~ACE_MEM_SAP.


The documentation for this class was generated from the following files:
Generated on Mon Jun 16 12:50:21 2003 for ACE by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002