Represents a node in the queue of incoming messages. More...
#include <Queued_Data.h>
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::Boolean | 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 |
Get the state. | |
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 | |
size_t | missing_data_ |
Represents a node in the queue of incoming messages.
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.
TAO_Queued_Data::TAO_Queued_Data | ( | ACE_Allocator * | alloc = 0 |
) |
Default Constructor.
Definition at line 34 of file Queued_Data.inl.
: msg_block_ (0), missing_data_ (0), state_ (), next_ (0), allocator_ (alloc) { }
TAO_Queued_Data::TAO_Queued_Data | ( | ACE_Message_Block * | mb, | |
ACE_Allocator * | alloc = 0 | |||
) |
Constructor.
Definition at line 44 of file Queued_Data.inl.
: msg_block_ (mb), missing_data_ (0), state_ (), next_ (0), allocator_ (alloc) { }
TAO_Queued_Data::TAO_Queued_Data | ( | const TAO_Queued_Data & | qd | ) |
Copy constructor.
Definition at line 55 of file Queued_Data.inl.
: msg_block_ (qd.msg_block_->duplicate ()), missing_data_ (qd.missing_data_), state_ (qd.state_), next_ (0), allocator_ (qd.allocator_) { }
CORBA::Octet TAO_Queued_Data::byte_order | ( | void | ) | const |
Get byte_order.
Definition at line 84 of file Queued_Data.inl.
{ return this->state_.byte_order (); }
int TAO_Queued_Data::consolidate | ( | void | ) |
Consolidate this fragments chained message blocks into one.
Definition at line 205 of file Queued_Data.cpp.
{ // Is this a chain of fragments? if (this->state_.more_fragments () && this->msg_block_->cont () != 0) { // Create a message block big enough to hold the entire chain ACE_Message_Block *dest = clone_mb_nocopy_size ( this->msg_block_, this->msg_block_->total_length ()); if (0 == dest) { // out of memory return -1; } // Memory allocation succeeded, the new message block can hold the consolidated // message. The following code just copies all the data into this new message block. // No further memory allocation will take place. // Reset the cont() parameter. We have cloned the message // block but not the chain as we will no longer have chain. dest->cont (0); // Use ACE_CDR to consolidate the chain for us ACE_CDR::consolidate (dest, this->msg_block_); // free the original message block chain this->msg_block_->release (); // Set the message block to the new consolidated message block this->msg_block_ = dest; this->state_.more_fragments (false); } return 0; }
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.
{ // Check to see if the underlying block is on the stack. If not it // is fine. If the datablock is on stack, try to make a copy of that // before doing a duplicate. // @@ todo: Theoretically this should be within the Message Block, // but we dont have much scope to do this in that mess. Probably in // the next stage of MB rewrite we should be okay ACE_Message_Block::Message_Flags fl = sqd.msg_block_->self_flags (); if (ACE_BIT_ENABLED (fl, ACE_Message_Block::DONT_DELETE)) (void) TAO_Queued_Data::replace_data_block (*sqd.msg_block_); TAO_Queued_Data *qd = 0; if (sqd.allocator_) { ACE_NEW_MALLOC_RETURN (qd, static_cast<TAO_Queued_Data *> ( sqd.allocator_->malloc (sizeof (TAO_Queued_Data))), TAO_Queued_Data (sqd), 0); return qd; } // No allocator, so use the global pool! // @@ TODO: We should be removing this at some point of time! if (TAO_debug_level == 4) { // This debug is for testing purposes! ACE_DEBUG ((LM_DEBUG, "TAO (%P|%t) - Queued_Data[%d]::duplicate\n", "Using global pool for allocation\n")); } ACE_NEW_RETURN (qd, TAO_Queued_Data (sqd), 0); return qd; }
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.
{ return this->state_.giop_version (); }
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.
{ // Get a node for the queue.. TAO_Queued_Data *qd = 0; if (message_buffer_alloc) { ACE_NEW_MALLOC_RETURN (qd, static_cast<TAO_Queued_Data *> ( message_buffer_alloc->malloc (sizeof (TAO_Queued_Data))), TAO_Queued_Data (message_buffer_alloc), 0); } else { // No allocator, so use the global pool! ACE_NEW_RETURN (qd, TAO_Queued_Data, 0); } // Providing an ACE_Data_Block indicates that the caller wants // an aligned ACE_Message_Block added to the TAO_Queued_Data. if (db != 0) { // If this allocation fails, the TAO_Queued_Data will be leaked. if (input_cdr_alloc == 0) ACE_NEW_RETURN (qd->msg_block_, ACE_Message_Block (db, 0, input_cdr_alloc), 0); else ACE_NEW_MALLOC_RETURN (qd->msg_block_, static_cast<ACE_Message_Block*> ( input_cdr_alloc->malloc (sizeof (ACE_Message_Block))), ACE_Message_Block (db, 0, input_cdr_alloc), 0); ACE_CDR::mb_align (qd->msg_block_); } return qd; }
size_t TAO_Queued_Data::missing_data | ( | void | ) | const |
void TAO_Queued_Data::missing_data | ( | size_t | data | ) |
CORBA::Boolean TAO_Queued_Data::more_fragments | ( | void | ) | const |
Get more fragments.
Definition at line 90 of file Queued_Data.inl.
{ return this->state_.more_fragments (); }
ACE_Message_Block * TAO_Queued_Data::msg_block | ( | void | ) | const |
void TAO_Queued_Data::msg_block | ( | ACE_Message_Block * | mb | ) |
GIOP::MsgType TAO_Queued_Data::msg_type | ( | void | ) | const |
Get message type.
Definition at line 96 of file Queued_Data.inl.
{ return this->state_.message_type (); }
TAO_Queued_Data * TAO_Queued_Data::next | ( | void | ) | const |
void TAO_Queued_Data::next | ( | TAO_Queued_Data * | qd | ) |
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.
{ //// TODO ACE_Message_Block::release (qd->msg_block_); if (qd->allocator_) { ACE_DES_FREE (qd, qd->allocator_->free, TAO_Queued_Data); return; } // @todo: Need to be removed at some point of time! if (TAO_debug_level == 4) { // This debug is for testing purposes! ACE_DEBUG ((LM_DEBUG, "TAO (%P|%t) - Queued_Data[%d]::release\n", "Using global pool for releasing\n")); } delete qd; }
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.
{ size_t const newsize = ACE_CDR::total_length (&mb, 0) + ACE_CDR::MAX_ALIGNMENT; ACE_Data_Block *db = mb.data_block ()->clone_nocopy (); if (db->size (newsize) == -1) return; ACE_Message_Block tmp (db); ACE_CDR::mb_align (&tmp); tmp.copy (mb.rd_ptr (), mb.length()); mb.data_block (tmp.data_block ()->duplicate ()); mb.rd_ptr (tmp.rd_ptr ()); mb.wr_ptr (tmp.wr_ptr ()); // Remove the DONT_DELETE flags from mb mb.clr_self_flags (ACE_Message_Block::DONT_DELETE); }
const TAO_GIOP_Message_State & TAO_Queued_Data::state | ( | void | ) | const |
void TAO_Queued_Data::state | ( | const TAO_GIOP_Message_State & | state | ) |
ACE_Allocator* TAO_Queued_Data::allocator_ [private] |
The allocator used to allocate this class.
Definition at line 141 of file Queued_Data.h.
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 127 of file Queued_Data.h.
ACE_Message_Block* TAO_Queued_Data::msg_block_ [private] |
The message block that contains the message.
Definition at line 115 of file Queued_Data.h.
TAO_Queued_Data* TAO_Queued_Data::next_ [private] |
Pounter to the next element in the queue.
Definition at line 134 of file Queued_Data.h.
State of this queued data.
Definition at line 131 of file Queued_Data.h.