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


Public Types | |
| enum | Signal_Strategy { Reactive, MT } |
Public Member Functions | |
| ACE_MEM_IO (void) | |
| Constructor. | |
| ~ACE_MEM_IO (void) | |
| Destructor. | |
| 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) |
| ssize_t | recv (void *buf, size_t n, int flags) |
| Recv an byte buffer from the shm_malloc_ thru connected socket. | |
| ssize_t | send (const void *buf, size_t n) |
| ssize_t | recv (void *buf, size_t n) |
| Recv an byte buffer from the shm_malloc_ thru connected socket. | |
| 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. | |
Public Attributes | |
| ACE_ALLOC_HOOK_DECLARE | |
| Declare the dynamic allocation hooks. | |
Private Member Functions | |
| ssize_t | fetch_recv_buf (int flag, const ACE_Time_Value *timeout) |
Private Attributes | |
| ACE_MEM_SAP * | deliver_strategy_ |
| Actual deliverying mechanism. | |
| ACE_MEM_SAP_Node * | recv_buffer_ |
| Internal pointer for support recv/send. | |
| ssize_t | buf_size_ |
| Record the current total buffer size of . | |
| ssize_t | cur_offset_ |
| Record the current read pointer location in . | |
Definition at line 170 of file MEM_IO.h.
|
|
Definition at line 180 of file MEM_IO.h.
00181 {
00182 Reactive,
00183 MT
00184 } Signal_Strategy;
|
|
|
Constructor.
Definition at line 78 of file MEM_IO.inl.
00079 : deliver_strategy_ (0), 00080 recv_buffer_ (0), 00081 buf_size_ (0), 00082 cur_offset_ (0) 00083 { 00084 // ACE_TRACE ("ACE_MEM_IO::ACE_MEM_IO"); 00085 } |
|
|
Destructor.
Definition at line 116 of file MEM_IO.inl. References deliver_strategy_.
00117 {
00118 delete this->deliver_strategy_;
00119 }
|
|
|
Dump the state of an object.
Reimplemented from ACE_SOCK. Reimplemented in ACE_MEM_Stream. Definition at line 311 of file MEM_IO.cpp. References ACE_TRACE.
00312 {
00313 #if defined (ACE_HAS_DUMP)
00314 ACE_TRACE ("ACE_MEM_IO::dump");
00315 #endif /* ACE_HAS_DUMP */
00316 }
|
|
||||||||||||
|
Return the local endpoint port number. Returns 0 if successful, else -1. Definition at line 88 of file MEM_IO.inl. References ACE_ASSERT, ACE_TRACE, buf_size_, cur_offset_, deliver_strategy_, ACE_MEM_SAP::recv_buf(), recv_buffer_, ACE_MEM_SAP::release_buffer(), and ssize_t. Referenced by recv().
00089 {
00090 ACE_TRACE ("ACE_MEM_IO::fetch_recv_buf");
00091
00092 if (this->deliver_strategy_ == 0)
00093 return -1;
00094
00095 // This method can only be called when <buf_size_> == <cur_offset_>.
00096 ACE_ASSERT (this->buf_size_ == this->cur_offset_);
00097
00098 // We have done using the previous buffer, return it to malloc.
00099 if (this->recv_buffer_ != 0)
00100 this->deliver_strategy_->release_buffer (this->recv_buffer_);
00101
00102 this->cur_offset_ = 0;
00103 ssize_t retv = 0;
00104
00105 if ((retv = this->deliver_strategy_->recv_buf (this->recv_buffer_,
00106 flag,
00107 timeout)) > 0)
00108 this->buf_size_ = retv;
00109 else
00110 this->buf_size_ = 0;
00111
00112 return retv;
00113 }
|
|
|
Finalizing the MEM_IO object. This method doesn't invoke the 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, and Reactive. 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 amount of time to receive up to bytes into from (uses the call). If times out a -1 is returned with <errno == ETIME>. If it succeeds the number of bytes received is returned. Definition at line 146 of file MEM_IO.inl. References ACE_TRACE, buf_size_, cur_offset_, fetch_recv_buf(), ACE_OS::memcpy(), and ssize_t.
00150 {
00151 ACE_TRACE ("ACE_MEM_IO::recv");
00152
00153 size_t count = 0;
00154
00155 // while (len > 0)
00156 // {
00157 size_t buf_len = this->buf_size_ - this->cur_offset_;
00158 if (buf_len == 0)
00159 {
00160 ssize_t blen = // Buffer length
00161 this->fetch_recv_buf (flags, timeout);
00162 if (blen <= 0)
00163 return blen;
00164 buf_len = this->buf_size_;
00165 }
00166
00167 size_t length = (len > buf_len ? buf_len : len);
00168
00169 ACE_OS::memcpy ((char *) buf + count,
00170 (char *) this->recv_buffer_->data () + this->cur_offset_,
00171 length);
00172 this->cur_offset_ += length;
00173 // len -= length;
00174 count += length;
00175 // }
00176
00177 return count;
00178 }
|
|
||||||||||||||||
|
Wait up to amount of time to receive up to bytes into from (uses the call). If times out a -1 is returned with <errno == ETIME>. If it succeeds the number of bytes received is returned. Definition at line 216 of file MEM_IO.inl. References ACE_TRACE, and recv().
|
|
||||||||||||
|
Recv an byte buffer from the shm_malloc_ thru connected socket.
Definition at line 208 of file MEM_IO.inl. References ACE_TRACE, and recv().
|
|
||||||||||||||||
|
Recv an byte buffer from the shm_malloc_ thru connected socket.
Definition at line 190 of file MEM_IO.inl. References ACE_TRACE. Referenced by recv(), and ACE_MEM_Stream::recv_n().
|
|
||||||||||||
|
Wait to to amount of time to send the . If 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_MEM_SAP::acquire_buffer(), ACE_Message_Block::cont(), ACE_MEM_SAP_Node::data(), deliver_strategy_, ACE_Message_Block::length(), ACE_OS::memcpy(), ACE_Message_Block::next(), ACE_Message_Block::rd_ptr(), ACE_MEM_SAP::send_buf(), ACE_MEM_SAP_Node::size_, 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 size_t len = message_block->total_length ();
00374
00375 if (len != 0)
00376 {
00377 ACE_MEM_SAP_Node *buf =
00378 reinterpret_cast<ACE_MEM_SAP_Node *> (
00379 this->deliver_strategy_->acquire_buffer (len));
00380 size_t n = 0;
00381 while (message_block != 0)
00382 {
00383 ACE_OS::memcpy (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 amount of time to send up to bytes into from (uses the call). If times out a -1 is returned with <errno == ETIME>. If it succeeds the number of bytes sent is returned. Definition at line 122 of file MEM_IO.inl. References ACE_TRACE, ACE_MEM_SAP::acquire_buffer(), ACE_MEM_SAP_Node::data(), deliver_strategy_, ACE_OS::memcpy(), ACE_MEM_SAP::send_buf(), and ACE_MEM_SAP_Node::size_.
00126 {
00127 ACE_TRACE ("ACE_MEM_IO::send");
00128 if (this->deliver_strategy_ == 0)
00129 return 0;
00130
00131 ACE_MEM_SAP_Node *sbuf = this->deliver_strategy_->acquire_buffer (len);
00132 if (sbuf == 0)
00133 return -1; // Memory buffer not initialized.
00134 ACE_OS::memcpy (sbuf->data (), buf, len);
00135
00136 ///
00137
00138 sbuf->size_ = len;
00139
00140 return this->deliver_strategy_->send_buf (sbuf,
00141 flags,
00142 timeout);
00143 }
|
|
||||||||||||||||
|
Wait to to amount of time to send up to bytes into from (uses the call). If times out a -1 is returned with <errno == ETIME>. If it succeeds the number of bytes sent is returned. Definition at line 225 of file MEM_IO.inl. References ACE_TRACE, and send().
|
|
||||||||||||
|
Send an byte buffer to the other process using shm_malloc_ connected thru the socket. Definition at line 199 of file MEM_IO.inl. References ACE_TRACE, and send().
|
|
||||||||||||||||
|
Send an byte buffer to the other process using shm_malloc_ connected thru the socket. Definition at line 181 of file MEM_IO.inl. 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 .
Definition at line 295 of file MEM_IO.h. Referenced by fetch_recv_buf(), and recv(). |
|
|
Record the current read pointer location in .
Definition at line 298 of file MEM_IO.h. Referenced by fetch_recv_buf(), and recv(). |
|
|
Actual deliverying mechanism.
Definition at line 289 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 292 of file MEM_IO.h. Referenced by fetch_recv_buf(). |
1.3.6