#include <Asynch_Queued_Message.h>
Inheritance diagram for TAO_Asynch_Queued_Message:
Public Member Functions | |
TAO_Asynch_Queued_Message (const ACE_Message_Block *contents, TAO_ORB_Core *oc, ACE_Allocator *alloc=0, bool is_heap_allocated=false) | |
Constructor. | |
virtual | ~TAO_Asynch_Queued_Message (void) |
Destructor. | |
Implement the Template Methods from TAO_Queued_Message | |
virtual size_t | message_length (void) const |
Return the length of the message. | |
virtual int | all_data_sent (void) const |
Return 1 if all the data has been sent. | |
virtual void | fill_iov (int iovcnt_max, int &iovcnt, iovec iov[]) const |
Fill up an io vector using the connects of the message. | |
virtual void | bytes_transferred (size_t &byte_count) |
Update the internal state, data has been sent. | |
virtual TAO_Queued_Message * | clone (ACE_Allocator *alloc) |
virtual void | destroy (void) |
Reclaim resources. | |
Protected Member Functions | |
TAO_Asynch_Queued_Message (char *buf, TAO_ORB_Core *oc, size_t size, ACE_Allocator *alloc=0) | |
Constructor. | |
Private Attributes | |
const size_t | size_ |
The number of bytes in the buffer. | |
size_t | offset_ |
The offset in the buffer. | |
char * | buffer_ |
The buffer containing the complete message. |
Definition at line 33 of file Asynch_Queued_Message.h.
|
Constructor.
Definition at line 19 of file Asynch_Queued_Message.cpp. References ACE_NEW, ACE_Message_Block::cont(), ACE_Message_Block::length(), ACE_OS::memcpy(), and ACE_Message_Block::rd_ptr(). Referenced by clone().
00024 : TAO_Queued_Message (oc, alloc, is_heap_allocated) 00025 , size_ (contents->total_length ()) 00026 , offset_ (0) 00027 { 00028 // @@ Use a pool for these guys!! 00029 ACE_NEW (this->buffer_, char[this->size_]); 00030 00031 size_t copy_offset = 0; 00032 for (const ACE_Message_Block *i = contents; 00033 i != 0; 00034 i = i->cont ()) 00035 { 00036 ACE_OS::memcpy (this->buffer_ + copy_offset, 00037 i->rd_ptr (), 00038 i->length ()); 00039 copy_offset += i->length (); 00040 } 00041 } |
|
Destructor.
Definition at line 54 of file Asynch_Queued_Message.cpp.
00055 { 00056 // @@ Use a pool for these guys! 00057 delete [] this->buffer_; 00058 } |
|
Constructor.
Definition at line 43 of file Asynch_Queued_Message.cpp.
00047 : TAO_Queued_Message (oc, alloc) 00048 , size_ (size) 00049 , offset_ (0) 00050 , buffer_ (buf) 00051 { 00052 } |
|
Return 1 if all the data has been sent.
Implements TAO_Queued_Message. Definition at line 67 of file Asynch_Queued_Message.cpp. Referenced by bytes_transferred().
|
|
Update the internal state, data has been sent. After the TAO_Transport class completes a successful (or partially successful) I/O operation it must update the state of all the messages queued. This callback method is used by each message to update its state and determine if all the data has been sent already.
Implements TAO_Queued_Message. Definition at line 86 of file Asynch_Queued_Message.cpp. References all_data_sent(), TAO_LF_Event::state_changed(), and TAO_LF_Invocation_Event::state_changed_i().
00087 { 00088 this->state_changed_i (TAO_LF_Event::LFS_ACTIVE); 00089 00090 size_t const remaining_bytes = this->size_ - this->offset_; 00091 if (byte_count > remaining_bytes) 00092 { 00093 this->offset_ = this->size_; 00094 byte_count -= remaining_bytes; 00095 return; 00096 } 00097 this->offset_ += byte_count; 00098 byte_count = 0; 00099 00100 if (this->all_data_sent ()) 00101 this->state_changed (TAO_LF_Event::LFS_SUCCESS, 00102 this->orb_core_->leader_follower ()); 00103 } |
|
Implements TAO_Queued_Message. Definition at line 107 of file Asynch_Queued_Message.cpp. References ACE_DEBUG, ACE_NEW_MALLOC_RETURN, ACE_NEW_RETURN, TAO_Queued_Message::is_heap_created_, LM_DEBUG, ACE_Allocator::malloc(), ACE_OS::memcpy(), TAO_Asynch_Queued_Message(), and TAO_debug_level.
00108 { 00109 char *buf = 0; 00110 00111 // @@todo: Need to use a memory pool. But certain things need to 00112 // change a bit in this class for that. Till then. 00113 00114 // Just allocate and copy data that needs to be sent, no point 00115 // copying the whole buffer. 00116 size_t const sz = this->size_ - this->offset_; 00117 00118 ACE_NEW_RETURN (buf, 00119 char[sz], 00120 0); 00121 00122 ACE_OS::memcpy (buf, 00123 this->buffer_ + this->offset_, 00124 sz); 00125 00126 TAO_Asynch_Queued_Message *qm = 0; 00127 00128 if (alloc) 00129 { 00130 ACE_NEW_MALLOC_RETURN (qm, 00131 static_cast<TAO_Asynch_Queued_Message *> ( 00132 alloc->malloc (sizeof (TAO_Asynch_Queued_Message))), 00133 TAO_Asynch_Queued_Message (buf, 00134 this->orb_core_, 00135 sz, 00136 alloc), 00137 0); 00138 } 00139 else 00140 { 00141 // No allocator, so use the common heap! 00142 if (TAO_debug_level == 4) 00143 { 00144 // This debug is for testing purposes! 00145 ACE_DEBUG ((LM_DEBUG, 00146 "TAO (%P|%t) - Asynch_Queued_Message::clone\n" 00147 "Using global pool for allocation \n")); 00148 } 00149 00150 ACE_NEW_RETURN (qm, 00151 TAO_Asynch_Queued_Message (buf, 00152 this->orb_core_, 00153 sz), 00154 0); 00155 } 00156 00157 // Set the flag to indicate that <qm> is created on the heap. 00158 if (qm) 00159 qm->is_heap_created_ = true; 00160 00161 return qm; 00162 } |
|
Reclaim resources. Reliable messages are allocated from the stack, thus they do not be deallocated. Asynchronous (SYNC_NONE) messages are allocated from the heap (or a pool), they need to be reclaimed explicitly. Implements TAO_Queued_Message. Definition at line 165 of file Asynch_Queued_Message.cpp. References ACE_DES_FREE.
00166 { 00167 if (this->is_heap_created_) 00168 { 00169 // If we have an allocator release the memory to the allocator 00170 // pool. 00171 if (this->allocator_) 00172 { 00173 ACE_DES_FREE (this, 00174 this->allocator_->free, 00175 TAO_Asynch_Queued_Message); 00176 00177 } 00178 else // global release.. 00179 { 00180 delete this; 00181 } 00182 } 00183 00184 } |
|
Fill up an io vector using the connects of the message. Different versions of this class represent the message using either a single buffer, or a message block. This method allows a derived class to fill up the contents of an io vector, the TAO_Transport class uses this method to group as many messages as possible in an iovector before sending them to the OS I/O subsystem.
Implements TAO_Queued_Message. Definition at line 73 of file Asynch_Queued_Message.cpp. References ACE_ASSERT, iovec::iov_base, and iovec::iov_len.
|
|
Return the length of the message. If the message has been partially sent it returns the number of bytes that are still not sent. Implements TAO_Queued_Message. Definition at line 61 of file Asynch_Queued_Message.cpp.
|
|
The buffer containing the complete message.
Definition at line 99 of file Asynch_Queued_Message.h. |
|
The offset in the buffer.
Data up to Definition at line 96 of file Asynch_Queued_Message.h. |
|
The number of bytes in the buffer.
Definition at line 89 of file Asynch_Queued_Message.h. |