#include <Queued_Data.h>
Collaboration diagram for TAO_Queued_Data:
Public Member Functions | |
TAO_Queued_Data (ACE_Allocator *alloc=0) | |
Default Constructor. | |
TAO_Queued_Data (ACE_Message_Block *mb, ACE_Allocator *alloc=0) | |
Constructor. | |
TAO_Queued_Data (const TAO_Queued_Data &qd) | |
Copy constructor. | |
int | consolidate (void) |
size_t | missing_data (void) const |
Get missing data. | |
void | missing_data (size_t data) |
Set missing data. | |
TAO_GIOP_Message_Version const & | giop_version (void) const |
Get the GIOP version. | |
CORBA::Octet | byte_order (void) const |
Get byte_order. | |
CORBA::Octet | more_fragments (void) const |
Get more fragments. | |
GIOP::MsgType | msg_type (void) const |
Get message type. | |
TAO_Queued_Data * | next (void) const |
Get next. | |
void | next (TAO_Queued_Data *qd) |
Set next. | |
ACE_Message_Block * | msg_block (void) const |
Get message block. | |
void | msg_block (ACE_Message_Block *mb) |
Set message block. | |
void | state (const TAO_GIOP_Message_State &state) |
Set the state. | |
const TAO_GIOP_Message_State & | state (void) const |
Static Public Member Functions | |
static TAO_Queued_Data * | make_queued_data (ACE_Allocator *message_buffer_alloc=0, ACE_Allocator *input_cdr_alloc=0, ACE_Data_Block *db=0) |
Creation of a node in the queue. | |
static void | release (TAO_Queued_Data *qd) |
Deletion of a node from the queue. | |
static TAO_Queued_Data * | duplicate (TAO_Queued_Data &qd) |
Static Private Member Functions | |
static void | replace_data_block (ACE_Message_Block &mb) |
Private Attributes | |
ACE_Message_Block * | msg_block_ |
The message block that contains the message. | |
TAO_GIOP_Message_State | state_ |
State of this queued data. | |
TAO_Queued_Data * | next_ |
Pounter to the next element in the queue. | |
ACE_Allocator * | allocator_ |
The allocator used to allocate this class. | |
Missing Data details | |
The missing_data_ member contains the number of bytes of data missing from msg_block_. | |
size_t | missing_data_ |
This class contains necessary information about a message that is stored in the queue. Such a node can be used by the incoming thread from the reactor to dequeue and process the message by sending it to the higher layers of the ORB.
The ACE_Message_Block contained within this class may contain a chain of message blocks (usually when GIOP fragments are involved). In that case consolidate () needs to be called prior to being sent to higher layers of the ORB when the GIOP fragment chain is complete.
Definition at line 47 of file Queued_Data.h.
ACE_INLINE TAO_Queued_Data::TAO_Queued_Data | ( | ACE_Allocator * | alloc = 0 |
) |
Default Constructor.
Definition at line 34 of file Queued_Data.inl.
00035 : msg_block_ (0), 00036 missing_data_ (0), 00037 state_ (), 00038 next_ (0), 00039 allocator_ (alloc) 00040 { 00041 }
ACE_INLINE TAO_Queued_Data::TAO_Queued_Data | ( | ACE_Message_Block * | mb, | |
ACE_Allocator * | alloc = 0 | |||
) |
Constructor.
Definition at line 44 of file Queued_Data.inl.
00046 : msg_block_ (mb), 00047 missing_data_ (0), 00048 state_ (), 00049 next_ (0), 00050 allocator_ (alloc) 00051 { 00052 }
ACE_INLINE TAO_Queued_Data::TAO_Queued_Data | ( | const TAO_Queued_Data & | qd | ) |
Copy constructor.
Definition at line 55 of file Queued_Data.inl.
00056 : msg_block_ (qd.msg_block_->duplicate ()), 00057 missing_data_ (qd.missing_data_), 00058 state_ (qd.state_), 00059 next_ (0), 00060 allocator_ (qd.allocator_) 00061 { 00062 }
ACE_INLINE CORBA::Octet TAO_Queued_Data::byte_order | ( | void | ) | const |
Get byte_order.
Definition at line 84 of file Queued_Data.inl.
References TAO_GIOP_Message_State::byte_order(), and state_.
Referenced by TAO_GIOP_Message_Base::parse_request_id(), TAO_GIOP_Message_Base::process_reply_message(), and TAO_GIOP_Message_Base::process_request_message().
00085 { 00086 return this->state_.byte_order (); 00087 }
int TAO_Queued_Data::consolidate | ( | void | ) |
Consolidate this fragments chained message blocks into one.
Definition at line 205 of file Queued_Data.cpp.
References clone_mb_nocopy_size(), ACE_CDR::consolidate(), ACE_Message_Block::cont(), TAO_GIOP_Message_State::more_fragments(), msg_block_, ACE_Message_Block::release(), and state_.
Referenced by TAO_GIOP_Message_Base::consolidate_fragmented_message().
00206 { 00207 // Is this a chain of fragments? 00208 if (this->state_.more_fragments () && this->msg_block_->cont () != 0) 00209 { 00210 // Create a message block big enough to hold the entire chain 00211 ACE_Message_Block *dest = clone_mb_nocopy_size ( 00212 this->msg_block_, 00213 this->msg_block_->total_length ()); 00214 00215 if (0 == dest) 00216 { 00217 // out of memory 00218 return -1; 00219 } 00220 // Memory allocation succeeded, the new message block can hold the consolidated 00221 // message. The following code just copies all the data into this new message block. 00222 // No further memory allocation will take place. 00223 00224 // Reset the cont() parameter. We have cloned the message 00225 // block but not the chain as we will no longer have chain. 00226 dest->cont (0); 00227 00228 // Use ACE_CDR to consolidate the chain for us 00229 ACE_CDR::consolidate (dest, this->msg_block_); 00230 00231 // free the original message block chain 00232 this->msg_block_->release (); 00233 00234 // Set the message block to the new consolidated message block 00235 this->msg_block_ = dest; 00236 this->state_.more_fragments (0); 00237 } 00238 00239 return 0; 00240 }
TAO_Queued_Data * TAO_Queued_Data::duplicate | ( | TAO_Queued_Data & | qd | ) | [static] |
Duplicate ourselves. This creates a copy of ourselves on the heap and returns a pointer to the duplicated node.
Definition at line 158 of file Queued_Data.cpp.
References ACE_BIT_ENABLED, ACE_DEBUG, ACE_NEW_MALLOC_RETURN, ACE_NEW_RETURN, allocator_, ACE_Message_Block::DONT_DELETE, LM_DEBUG, ACE_Allocator::malloc(), msg_block_, replace_data_block(), ACE_Message_Block::self_flags(), and TAO_debug_level.
Referenced by TAO_Transport::handle_input_parse_data().
00159 { 00160 // Check to see if the underlying block is on the stack. If not it 00161 // is fine. If the datablock is on stack, try to make a copy of that 00162 // before doing a duplicate. 00163 // @@ todo: Theoretically this should be within the Message Block, 00164 // but we dont have much scope to do this in that mess. Probably in 00165 // the next stage of MB rewrite we should be okay 00166 ACE_Message_Block::Message_Flags fl = 00167 sqd.msg_block_->self_flags (); 00168 00169 if (ACE_BIT_ENABLED (fl, 00170 ACE_Message_Block::DONT_DELETE)) 00171 (void) TAO_Queued_Data::replace_data_block (*sqd.msg_block_); 00172 00173 00174 TAO_Queued_Data *qd = 0; 00175 00176 if (sqd.allocator_) 00177 { 00178 ACE_NEW_MALLOC_RETURN (qd, 00179 static_cast<TAO_Queued_Data *> ( 00180 sqd.allocator_->malloc (sizeof (TAO_Queued_Data))), 00181 TAO_Queued_Data (sqd), 00182 0); 00183 00184 return qd; 00185 } 00186 00187 // No allocator, so use the global pool! 00188 // @@ TODO: We should be removing this at some point of time! 00189 if (TAO_debug_level == 4) 00190 { 00191 // This debug is for testing purposes! 00192 ACE_DEBUG ((LM_DEBUG, 00193 "TAO (%P|%t) - Queued_Data[%d]::duplicate\n", 00194 "Using global pool for allocation \n")); 00195 } 00196 00197 ACE_NEW_RETURN (qd, 00198 TAO_Queued_Data (sqd), 00199 0); 00200 00201 return qd; 00202 }
ACE_INLINE TAO_GIOP_Message_Version const & TAO_Queued_Data::giop_version | ( | void | ) | const |
Get the GIOP version.
Definition at line 78 of file Queued_Data.inl.
References TAO_GIOP_Message_State::giop_version(), and state_.
Referenced by TAO_GIOP_Message_Base::consolidate_fragmented_message(), TAO_GIOP_Message_Base::discard_fragmented_message(), TAO_GIOP_Message_Base::parse_request_id(), TAO_GIOP_Message_Base::process_reply_message(), and TAO_GIOP_Message_Base::process_request_message().
00079 { 00080 return this->state_.giop_version (); 00081 }
TAO_Queued_Data * TAO_Queued_Data::make_queued_data | ( | ACE_Allocator * | message_buffer_alloc = 0 , |
|
ACE_Allocator * | input_cdr_alloc = 0 , |
|||
ACE_Data_Block * | db = 0 | |||
) | [static] |
Creation of a node in the queue.
Definition at line 78 of file Queued_Data.cpp.
References ACE_NEW_MALLOC_RETURN, ACE_NEW_RETURN, ACE_Allocator::malloc(), ACE_CDR::mb_align(), and msg_block_.
Referenced by TAO_GIOP_Message_Base::make_queued_data().
00081 { 00082 // Get a node for the queue.. 00083 TAO_Queued_Data *qd = 0; 00084 00085 if (message_buffer_alloc) 00086 { 00087 ACE_NEW_MALLOC_RETURN (qd, 00088 static_cast<TAO_Queued_Data *> ( 00089 message_buffer_alloc->malloc (sizeof (TAO_Queued_Data))), 00090 TAO_Queued_Data (message_buffer_alloc), 00091 0); 00092 00093 } 00094 else 00095 { 00096 // No allocator, so use the global pool! 00097 ACE_NEW_RETURN (qd, 00098 TAO_Queued_Data, 00099 0); 00100 } 00101 00102 // Providing an ACE_Data_Block indicates that the caller wants 00103 // an aligned ACE_Message_Block added to the TAO_Queued_Data. 00104 if (db != 0) 00105 { 00106 // If this allocation fails, the TAO_Queued_Data will be leaked. 00107 if (input_cdr_alloc == 0) 00108 ACE_NEW_RETURN (qd->msg_block_, 00109 ACE_Message_Block (db, 00110 0, 00111 input_cdr_alloc), 00112 0); 00113 else 00114 ACE_NEW_MALLOC_RETURN (qd->msg_block_, 00115 static_cast<ACE_Message_Block*> ( 00116 input_cdr_alloc->malloc (sizeof (ACE_Message_Block))), 00117 ACE_Message_Block (db, 00118 0, 00119 input_cdr_alloc), 00120 0); 00121 00122 ACE_CDR::mb_align (qd->msg_block_); 00123 } 00124 00125 return qd; 00126 }
ACE_INLINE void TAO_Queued_Data::missing_data | ( | size_t | data | ) |
Set missing data.
Definition at line 72 of file Queued_Data.inl.
References missing_data_.
00073 { 00074 this->missing_data_ = data; 00075 }
ACE_INLINE size_t TAO_Queued_Data::missing_data | ( | void | ) | const |
Get missing data.
Definition at line 66 of file Queued_Data.inl.
References missing_data_.
Referenced by TAO_Transport::consolidate_enqueue_message(), TAO_GIOP_Message_Base::consolidate_node(), TAO_Transport::consolidate_process_message(), TAO_GIOP_Message_Base::extract_next_message(), TAO_Transport::handle_input(), TAO_Transport::handle_input_missing_data(), TAO_Transport::handle_input_parse_data(), TAO_Transport::handle_input_parse_extra_messages(), TAO_GIOP_Message_Base::parse_next_message(), and TAO_Transport::process_parsed_messages().
00067 { 00068 return this->missing_data_; 00069 }
ACE_INLINE CORBA::Octet TAO_Queued_Data::more_fragments | ( | void | ) | const |
Get more fragments.
Definition at line 90 of file Queued_Data.inl.
References TAO_GIOP_Message_State::more_fragments(), and state_.
Referenced by TAO_Transport::consolidate_enqueue_message(), TAO_GIOP_Message_Base::consolidate_fragmented_message(), and TAO_Transport::consolidate_process_message().
00091 { 00092 return this->state_.more_fragments (); 00093 }
ACE_INLINE void TAO_Queued_Data::msg_block | ( | ACE_Message_Block * | mb | ) |
Set message block.
Definition at line 120 of file Queued_Data.inl.
References msg_block_.
00121 { 00122 this->msg_block_ = mb; 00123 }
ACE_INLINE ACE_Message_Block * TAO_Queued_Data::msg_block | ( | void | ) | const |
Get message block.
Definition at line 114 of file Queued_Data.inl.
References msg_block_.
Referenced by TAO_GIOP_Message_Base::consolidate_fragmented_message(), TAO_GIOP_Message_Base::consolidate_node(), TAO_GIOP_Message_Base::extract_next_message(), TAO_Transport::handle_input_missing_data(), TAO_Transport::handle_input_parse_data(), TAO_GIOP_Message_Base::parse_next_message(), TAO_GIOP_Message_Base::parse_request_id(), TAO_Transport::process_parsed_messages(), TAO_GIOP_Message_Base::process_reply_message(), and TAO_GIOP_Message_Base::process_request_message().
00115 { 00116 return this->msg_block_; 00117 }
ACE_INLINE GIOP::MsgType TAO_Queued_Data::msg_type | ( | void | ) | const |
Get message type.
Definition at line 96 of file Queued_Data.inl.
References TAO_GIOP_Message_State::message_type(), and state_.
Referenced by TAO_Transport::consolidate_enqueue_message(), TAO_Transport::consolidate_process_message(), TAO_GIOP_Message_Base::discard_fragmented_message(), TAO_GIOP_Message_Base::parse_request_id(), TAO_Transport::process_parsed_messages(), TAO_GIOP_Message_Base::process_reply_message(), and TAO_GIOP_Message_Base::process_request_message().
00097 { 00098 return this->state_.message_type (); 00099 }
ACE_INLINE void TAO_Queued_Data::next | ( | TAO_Queued_Data * | qd | ) |
Set next.
Definition at line 108 of file Queued_Data.inl.
References next_.
00109 { 00110 this->next_ = qd; 00111 }
ACE_INLINE TAO_Queued_Data * TAO_Queued_Data::next | ( | void | ) | const |
Get next.
Definition at line 102 of file Queued_Data.inl.
References next_.
Referenced by TAO_Incoming_Message_Queue::dequeue_head(), TAO_Incoming_Message_Queue::dequeue_tail(), TAO_Incoming_Message_Queue::enqueue_tail(), TAO::Incoming_Message_Stack::pop(), and TAO::Incoming_Message_Stack::push().
00103 { 00104 return this->next_; 00105 }
void TAO_Queued_Data::release | ( | TAO_Queued_Data * | qd | ) | [static] |
Deletion of a node from the queue.
Definition at line 130 of file Queued_Data.cpp.
References ACE_DEBUG, ACE_DES_FREE, allocator_, ACE_Allocator::free(), LM_DEBUG, msg_block_, ACE_Message_Block::release(), and TAO_debug_level.
Referenced by TAO_Transport::consolidate_enqueue_message(), TAO_GIOP_Message_Base::consolidate_fragmented_message(), TAO_Transport::consolidate_process_message(), TAO_GIOP_Message_Base::discard_fragmented_message(), TAO_Transport::process_queue_head(), TAO::Incoming_Message_Stack::~Incoming_Message_Stack(), and TAO_Incoming_Message_Queue::~TAO_Incoming_Message_Queue().
00131 { 00132 //// TODO 00133 ACE_Message_Block::release (qd->msg_block_); 00134 00135 if (qd->allocator_) 00136 { 00137 ACE_DES_FREE (qd, 00138 qd->allocator_->free, 00139 TAO_Queued_Data); 00140 00141 return; 00142 } 00143 00144 // @todo: Need to be removed at some point of time! 00145 if (TAO_debug_level == 4) 00146 { 00147 // This debug is for testing purposes! 00148 ACE_DEBUG ((LM_DEBUG, 00149 "TAO (%P|%t) - Queued_Data[%d]::release\n", 00150 "Using global pool for releasing \n")); 00151 } 00152 delete qd; 00153 00154 }
TAO_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE void TAO_Queued_Data::replace_data_block | ( | ACE_Message_Block & | mb | ) | [static, private] |
Replace the datablock with a one allocated on the heap or allocator
Definition at line 9 of file Queued_Data.inl.
References ACE_Data_Block::clone_nocopy(), ACE_Message_Block::clr_self_flags(), ACE_Message_Block::copy(), ACE_Message_Block::data_block(), ACE_Message_Block::DONT_DELETE, ACE_Data_Block::duplicate(), ACE_Message_Block::length(), ACE_CDR::MAX_ALIGNMENT, ACE_CDR::mb_align(), ACE_Message_Block::rd_ptr(), ACE_Data_Block::size(), ACE_CDR::total_length(), and ACE_Message_Block::wr_ptr().
Referenced by duplicate().
00010 { 00011 size_t const newsize = 00012 ACE_CDR::total_length (&mb, 0) + ACE_CDR::MAX_ALIGNMENT; 00013 00014 ACE_Data_Block *db = 00015 mb.data_block ()->clone_nocopy (); 00016 00017 if (db->size (newsize) == -1) 00018 return; 00019 00020 ACE_Message_Block tmp (db); 00021 ACE_CDR::mb_align (&tmp); 00022 00023 tmp.copy (mb.rd_ptr (), mb.length()); 00024 mb.data_block (tmp.data_block ()->duplicate ()); 00025 00026 mb.rd_ptr (tmp.rd_ptr ()); 00027 mb.wr_ptr (tmp.wr_ptr ()); 00028 00029 // Remove the DONT_DELETE flags from mb 00030 mb.clr_self_flags (ACE_Message_Block::DONT_DELETE); 00031 }
ACE_INLINE const TAO_GIOP_Message_State & TAO_Queued_Data::state | ( | void | ) | const |
Definition at line 132 of file Queued_Data.inl.
References state_.
Referenced by state().
00133 { 00134 return this->state_; 00135 }
ACE_INLINE void TAO_Queued_Data::state | ( | const TAO_GIOP_Message_State & | state | ) |
Set the state.
Definition at line 126 of file Queued_Data.inl.
References state(), and state_.
Referenced by TAO_GIOP_Message_Base::consolidate_node(), TAO_GIOP_Message_Base::extract_next_message(), and TAO_GIOP_Message_Base::parse_next_message().
ACE_Allocator* TAO_Queued_Data::allocator_ [private] |
The allocator used to allocate this class.
Definition at line 140 of file Queued_Data.h.
Referenced by duplicate(), and release().
size_t TAO_Queued_Data::missing_data_ [private] |
Data missing in the above message that hasn't been read or processed yet, the value TAO_MISSING_DATA_UNDEFINED indicates it hasn't been processed yet, otherwise greater or equal zero.
Definition at line 126 of file Queued_Data.h.
Referenced by missing_data().
ACE_Message_Block* TAO_Queued_Data::msg_block_ [private] |
The message block that contains the message.
Definition at line 114 of file Queued_Data.h.
Referenced by consolidate(), duplicate(), make_queued_data(), msg_block(), and release().
TAO_Queued_Data* TAO_Queued_Data::next_ [private] |
Pounter to the next element in the queue.
Definition at line 133 of file Queued_Data.h.
Referenced by next().
State of this queued data.
Definition at line 130 of file Queued_Data.h.
Referenced by byte_order(), consolidate(), giop_version(), more_fragments(), msg_type(), and state().