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


Public Types | |
| enum | Signal_Strategy { Reactive, MT } |
Public Methods | |
| ACE_MEM_IO (void) | |
| Constructor. More... | |
| ~ACE_MEM_IO (void) | |
| Destructor. More... | |
| int | init (const ACE_TCHAR *name, ACE_MEM_IO::Signal_Strategy type=ACE_MEM_IO::Reactive, ACE_MEM_SAP::MALLOC_OPTIONS *options=0) |
| int | fini (void) |
| ssize_t | send (const void *buf, size_t n, int flags) |
| Send an <n> byte buffer to the other process using shm_malloc_ connected thru the socket. More... | |
| ssize_t | recv (void *buf, size_t n, int flags) |
| Recv an <n> byte buffer from the shm_malloc_ thru connected socket. More... | |
| ssize_t | send (const void *buf, size_t n) |
| Send an <n> byte buffer to the other process using shm_malloc_ connected thru the socket. More... | |
| ssize_t | recv (void *buf, size_t n) |
| Recv an <n> byte buffer from the shm_malloc_ thru connected socket. More... | |
| ssize_t | send (const void *buf, size_t n, const ACE_Time_Value *timeout) |
| ssize_t | send (const void *buf, size_t n, int flags, const ACE_Time_Value *timeout) |
| ssize_t | send (const ACE_Message_Block *message_block, const ACE_Time_Value *timeout) |
| ssize_t | recv (void *buf, size_t n, const ACE_Time_Value *timeout) |
| ssize_t | recv (void *buf, size_t n, int flags, const ACE_Time_Value *timeout) |
| void | dump (void) const |
| Dump the state of an object. More... | |
Public Attributes | |
| ACE_ALLOC_HOOK_DECLARE | |
| Declare the dynamic allocation hooks. More... | |
Private Methods | |
| ssize_t | fetch_recv_buf (int flag, const ACE_Time_Value *timeout) |
| Return the local endpoint port number. Returns 0 if successful, else -1. More... | |
Private Attributes | |
| ACE_MEM_SAP * | deliver_strategy_ |
| Actual deliverying mechanism. More... | |
| ACE_MEM_SAP_Node * | recv_buffer_ |
| Internal pointer for support recv/send. More... | |
| ssize_t | buf_size_ |
| Record the current total buffer size of <recv_buffer_>. More... | |
| ssize_t | cur_offset_ |
| Record the current read pointer location in <recv_buffer_>. More... | |
Definition at line 163 of file MEM_IO.h.
|
|
Definition at line 173 of file MEM_IO.h. Referenced by ACE_MEM_Acceptor::accept, ACE_MEM_Connector::connect, init, ACE_MEM_Connector::preferred_strategy, and ACE_MEM_Acceptor::preferred_strategy.
00174 {
00175 Reactive,
00176 MT
00177 } Signal_Strategy;
|
|
|
Constructor.
Definition at line 77 of file MEM_IO.i.
00078 : deliver_strategy_ (0), 00079 recv_buffer_ (0), 00080 buf_size_ (0), 00081 cur_offset_ (0) 00082 { 00083 // ACE_TRACE ("ACE_MEM_IO::ACE_MEM_IO"); 00084 } |
|
|
Destructor.
Definition at line 115 of file MEM_IO.i. References deliver_strategy_.
00116 {
00117 delete this->deliver_strategy_;
00118 }
|
|
|
Dump the state of an object.
Reimplemented from ACE_SOCK. Reimplemented in ACE_MEM_Stream. Definition at line 313 of file MEM_IO.cpp. References ACE_TRACE.
00314 {
00315 ACE_TRACE ("ACE_MEM_IO::dump");
00316 }
|
|
||||||||||||
|
Return the local endpoint port number. Returns 0 if successful, else -1.
Definition at line 87 of file MEM_IO.i. References ACE_ASSERT, ACE_TRACE, buf_size_, cur_offset_, deliver_strategy_, ACE_MEM_SAP::recv_buf, recv_buffer_, and ACE_MEM_SAP::release_buffer. Referenced by recv.
00088 {
00089 ACE_TRACE ("ACE_MEM_IO::fetch_recv_buf");
00090
00091 if (this->deliver_strategy_ == 0)
00092 return -1;
00093
00094 // This method can only be called when <buf_size_> == <cur_offset_>.
00095 ACE_ASSERT (this->buf_size_ == this->cur_offset_);
00096
00097 // We have done using the previous buffer, return it to malloc.
00098 if (this->recv_buffer_ != 0)
00099 this->deliver_strategy_->release_buffer (this->recv_buffer_);
00100
00101 this->cur_offset_ = 0;
00102 int retv = 0;
00103
00104 if ((retv = this->deliver_strategy_->recv_buf (this->recv_buffer_,
00105 flag,
00106 timeout)) > 0)
00107 this->buf_size_ = retv;
00108 else
00109 this->buf_size_ = 0;
00110
00111 return retv;
00112 }
|
|
|
Finalizing the MEM_IO object. This method doesn't invoke the <remove> method. Definition at line 351 of file MEM_IO.cpp. References deliver_strategy_, and ACE_MEM_SAP::fini. Referenced by ACE_MEM_Stream::close.
00352 {
00353 if (this->deliver_strategy_ != 0)
00354 return this->deliver_strategy_->fini ();
00355 else
00356 return -1;
00357 }
|
|
||||||||||||||||
|
Initialize the MEM_SAP object. Definition at line 319 of file MEM_IO.cpp. References ACE_NEW_RETURN, ACE_TCHAR, deliver_strategy_, ACE_MEM_SAP::init, ACE_MEM_SAP::MALLOC_OPTIONS, MT, Reactive, and Signal_Strategy. Referenced by ACE_MEM_Acceptor::accept, and ACE_MEM_Connector::connect.
00322 {
00323 ACE_UNUSED_ARG (type);
00324
00325 delete this->deliver_strategy_;
00326 this->deliver_strategy_ = 0;
00327 switch (type)
00328 {
00329 case ACE_MEM_IO::Reactive:
00330 ACE_NEW_RETURN (this->deliver_strategy_,
00331 ACE_Reactive_MEM_IO (),
00332 -1);
00333 break;
00334 #if defined (ACE_WIN32) || !defined (_ACE_USE_SV_SEM)
00335 case ACE_MEM_IO::MT:
00336 ACE_NEW_RETURN (this->deliver_strategy_,
00337 ACE_MT_MEM_IO (),
00338 -1);
00339 break;
00340 #endif /* ACE_WIN32 || !_ACE_USE_SV_SEM */
00341 default:
00342 return -1;
00343 }
00344
00345 return this->deliver_strategy_->init (this->get_handle (),
00346 name,
00347 options);
00348 }
|
|
||||||||||||||||||||
|
Wait up to <timeout> amount of time to receive up to <n> bytes into <buf> from <handle> (uses the <recv> call). If <recv> times out a -1 is returned with <errno == ETIME>. If it succeeds the number of bytes received is returned. Definition at line 145 of file MEM_IO.i. References ACE_TRACE, buf_size_, cur_offset_, fetch_recv_buf, ACE_OS_String::memcpy, and ssize_t.
00149 {
00150 ACE_TRACE ("ACE_MEM_IO::recv");
00151
00152 size_t count = 0;
00153
00154 // while (len > 0)
00155 // {
00156 size_t buf_len = this->buf_size_ - this->cur_offset_;
00157 if (buf_len == 0)
00158 {
00159 ssize_t blen = // Buffer length
00160 this->fetch_recv_buf (flags, timeout);
00161 if (blen <= 0)
00162 return blen;
00163 buf_len = this->buf_size_;
00164 }
00165
00166 size_t length = (len > buf_len ? buf_len : len);
00167
00168 ACE_OS::memcpy ((char *) buf + count,
00169 (char *) this->recv_buffer_->data () + this->cur_offset_,
00170 length);
00171 this->cur_offset_ += length;
00172 // len -= length;
00173 count += length;
00174 // }
00175
00176 return count;
00177 }
|
|
||||||||||||||||
|
Wait up to <timeout> amount of time to receive up to <n> bytes into <buf> from <handle> (uses the <recv> call). If <recv> times out a -1 is returned with <errno == ETIME>. If it succeeds the number of bytes received is returned. Definition at line 215 of file MEM_IO.i. References ACE_TRACE, and recv.
|
|
||||||||||||
|
Recv an <n> byte buffer from the shm_malloc_ thru connected socket.
Definition at line 207 of file MEM_IO.i. References ACE_TRACE, and recv.
|
|
||||||||||||||||
|
Recv an <n> byte buffer from the shm_malloc_ thru connected socket.
Definition at line 189 of file MEM_IO.i. References ACE_TRACE. Referenced by recv, and ACE_MEM_Stream::recv_n.
|
|
||||||||||||
|
Wait to to <timeout> amount of time to send the <message_block>. If <send> times out a -1 is returned with <errno == ETIME>. If it succeeds the number of bytes sent is returned. Definition at line 365 of file MEM_IO.cpp. References ACE_TRACE, ACE_Message_Block::cont, ACE_MEM_SAP_Node::data, deliver_strategy_, ACE_Message_Block::length, ACE_OS_String::memcpy, ACE_Message_Block::next, ACE_Message_Block::rd_ptr, ACE_MEM_SAP::send_buf, ACE_MEM_SAP_Node::size_, ssize_t, and ACE_Message_Block::total_length.
00367 {
00368 ACE_TRACE ("ACE_MEM_IO::send");
00369
00370 if (this->deliver_strategy_ == 0)
00371 return -1; // Something went seriously wrong.
00372
00373 ssize_t len = message_block->total_length ();
00374
00375 if (len != 0)
00376 {
00377 ACE_MEM_SAP_Node *buf =
00378 ACE_reinterpret_cast (ACE_MEM_SAP_Node *,
00379 this->deliver_strategy_->acquire_buffer (len));
00380 ssize_t n = 0;
00381 while (message_block != 0)
00382 {
00383 ACE_OS::memcpy (ACE_static_cast (char *, buf->data ()) + n,
00384 message_block->rd_ptr (),
00385 message_block->length ());
00386 n += message_block->length ();
00387
00388 if (message_block->cont ())
00389 message_block = message_block->cont ();
00390 else
00391 message_block = message_block->next ();
00392 }
00393
00394 buf->size_ = len;
00395
00396 return this->deliver_strategy_->send_buf (buf,
00397 0,
00398 timeout);
00399 }
00400 return 0;
00401 }
|
|
||||||||||||||||||||
|
Wait to to <timeout> amount of time to send up to <n> bytes into <buf> from <handle> (uses the <send> call). If <send> times out a -1 is returned with <errno == ETIME>. If it succeeds the number of bytes sent is returned. Definition at line 121 of file MEM_IO.i. References ACE_TRACE, ACE_MEM_SAP::acquire_buffer, ACE_MEM_SAP_Node::data, deliver_strategy_, ACE_OS_String::memcpy, ACE_MEM_SAP::send_buf, and ACE_MEM_SAP_Node::size_.
00125 {
00126 ACE_TRACE ("ACE_MEM_IO::send");
00127 if (this->deliver_strategy_ == 0)
00128 return 0;
00129
00130 ACE_MEM_SAP_Node *sbuf = this->deliver_strategy_->acquire_buffer (len);
00131 if (sbuf == 0)
00132 return -1; // Memory buffer not initialized.
00133 ACE_OS::memcpy (sbuf->data (), buf, len);
00134
00135 ///
00136
00137 sbuf->size_ = len;
00138
00139 return this->deliver_strategy_->send_buf (sbuf,
00140 flags,
00141 timeout);
00142 }
|
|
||||||||||||||||
|
Wait to to <timeout> amount of time to send up to <n> bytes into <buf> from <handle> (uses the <send> call). If <send> times out a -1 is returned with <errno == ETIME>. If it succeeds the number of bytes sent is returned. Definition at line 224 of file MEM_IO.i. References ACE_TRACE, and send.
|
|
||||||||||||
|
Send an <n> byte buffer to the other process using shm_malloc_ connected thru the socket.
Definition at line 198 of file MEM_IO.i. References ACE_TRACE, and send.
|
|
||||||||||||||||
|
Send an <n> byte buffer to the other process using shm_malloc_ connected thru the socket.
Definition at line 180 of file MEM_IO.i. References ACE_TRACE. Referenced by ACE_MEM_Stream::close, send, and ACE_MEM_Stream::send_n.
|
|
|
Declare the dynamic allocation hooks.
Reimplemented from ACE_SOCK. Reimplemented in ACE_MEM_Stream. |
|
|
Record the current total buffer size of <recv_buffer_>.
Definition at line 288 of file MEM_IO.h. Referenced by fetch_recv_buf, and recv. |
|
|
Record the current read pointer location in <recv_buffer_>.
Definition at line 291 of file MEM_IO.h. Referenced by fetch_recv_buf, and recv. |
|
|
Actual deliverying mechanism.
Definition at line 282 of file MEM_IO.h. Referenced by fetch_recv_buf, fini, init, send, and ~ACE_MEM_IO. |
|
|
Internal pointer for support recv/send.
Definition at line 285 of file MEM_IO.h. Referenced by fetch_recv_buf. |
1.2.14 written by Dimitri van Heesch,
© 1997-2002