#include <MEM_IO.h>
Inheritance diagram for ACE_Reactive_MEM_IO:


Public Methods | |
| ACE_Reactive_MEM_IO (void) | |
| virtual | ~ACE_Reactive_MEM_IO (void) |
| virtual int | init (ACE_HANDLE handle, const ACE_TCHAR *name, MALLOC_OPTIONS *options) |
| virtual ssize_t | recv_buf (ACE_MEM_SAP_Node *&buf, int flags, const ACE_Time_Value *timeout) |
| virtual ssize_t | send_buf (ACE_MEM_SAP_Node *buf, int flags, const ACE_Time_Value *timeout) |
| ssize_t | get_buf_len (const off_t off, ACE_MEM_SAP_Node *&buf) |
|
|
Definition at line 7 of file MEM_IO.i.
00008 {
00009 }
|
|
|
Definition at line 18 of file MEM_IO.cpp.
00019 {
00020 }
|
|
||||||||||||
|
Convert the buffer offset <off> to absolute address to <buf>. Return the size of valid information containing in the <buf>, -1 if <shm_malloc_> is not initialized. Definition at line 49 of file MEM_IO.i. References ACE_SEH_EXCEPT, ACE_SEH_TRY, ACE_TRACE, ACE_MEM_SAP::shm_malloc_, ACE_MEM_SAP_Node::size, and ssize_t. Referenced by recv_buf.
00050 {
00051 #if !defined (ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS)
00052 ACE_TRACE ("ACE_Reactive_MEM_IO::get_buf_len");
00053 #endif /* ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS */
00054
00055 if (this->shm_malloc_ == 0)
00056 return -1;
00057
00058 ssize_t retv = 0;
00059
00060 ACE_SEH_TRY
00061 {
00062 buf = ACE_reinterpret_cast (ACE_MEM_SAP_Node *,
00063 (ACE_static_cast(char *,
00064 this->shm_malloc_->base_addr ())
00065 + off));
00066 retv = buf->size ();
00067 }
00068 ACE_SEH_EXCEPT (this->shm_malloc_->memory_pool ().seh_selector (GetExceptionInformation ()))
00069 {
00070 }
00071
00072 return retv;
00073 }
|
|
||||||||||||||||
|
Initialize the MEM_SAP object. Implements ACE_MEM_SAP. Definition at line 23 of file MEM_IO.cpp. References ACE_TCHAR, ACE_TRACE, ACE_MEM_SAP::create_shm_malloc, and ACE_MEM_SAP::handle_.
00026 {
00027 ACE_TRACE ("ACE_Reactive_MEM_IO::init");
00028 this->handle_ = handle;
00029 return this->create_shm_malloc (name,
00030 options);
00031 }
|
|
||||||||||||||||
|
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. Implements ACE_MEM_SAP. Definition at line 34 of file MEM_IO.cpp. References ACE_TRACE, get_buf_len, ACE_MEM_SAP::handle_, ACE::recv, ACE_MEM_SAP::shm_malloc_, and ssize_t.
00037 {
00038 ACE_TRACE ("ACE_Reactive_MEM_IO::recv_buf");
00039
00040 if (this->shm_malloc_ == 0 || this->handle_ == ACE_INVALID_HANDLE)
00041 return -1;
00042
00043 off_t new_offset = 0;
00044 ssize_t retv = ACE::recv (this->handle_,
00045 (char *) &new_offset,
00046 sizeof (off_t),
00047 flags,
00048 timeout);
00049
00050 if (retv == 0)
00051 {
00052 // ACE_DEBUG ((LM_INFO, "MEM_Stream closed\n"));
00053 buf = 0;
00054 return 0;
00055 }
00056 else if (retv != sizeof (off_t))
00057 {
00058 // Nothing available or we are really screwed.
00059 buf = 0;
00060 return -1;
00061 }
00062
00063 return this->get_buf_len (new_offset, buf);
00064 }
|
|
||||||||||||||||
|
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. Implements ACE_MEM_SAP. Definition at line 67 of file MEM_IO.cpp. References ACE_TRACE, ACE_MEM_SAP::handle_, ACE_MEM_SAP::release_buffer, ACE::send, ACE_MEM_SAP::shm_malloc_, and ACE_MEM_SAP_Node::size.
00070 {
00071 ACE_TRACE ("ACE_Reactive_MEM_IO::send_buf");
00072
00073 if (this->shm_malloc_ == 0 || this->handle_ == ACE_INVALID_HANDLE)
00074 return -1;
00075
00076 off_t offset = ACE_reinterpret_cast (char *, buf) -
00077 ACE_static_cast (char *, this->shm_malloc_->base_addr ());
00078 // the offset.
00079 // Send the offset value over the socket.
00080 if (ACE::send (this->handle_,
00081 (const char *) &offset,
00082 sizeof (offset),
00083 flags,
00084 timeout) != sizeof (offset))
00085 {
00086 // unsucessful send, release the memory in the shared-memory.
00087 this->release_buffer (buf);
00088
00089 return -1;
00090 }
00091 return buf->size ();
00092 }
|
1.2.14 written by Dimitri van Heesch,
© 1997-2002