Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

TAO_Incoming_Message_Queue Class Reference

A queue of the messages in the incoming data path. More...

#include <Incoming_Message_Queue.h>

Collaboration diagram for TAO_Incoming_Message_Queue:

Collaboration graph
[legend]
List of all members.

Public Methods

 TAO_Incoming_Message_Queue (TAO_ORB_Core *orb_core)
 Constructor. More...

 ~TAO_Incoming_Message_Queue (void)
 Destructor. More...

TAO_Queued_Datadequeue_head (void)
 Adding and deleting a node from the queue. More...

TAO_Queued_Datadequeue_tail (void)
int enqueue_tail (TAO_Queued_Data *nd)
size_t copy_tail (ACE_Message_Block &block)
 Copy message from <block> to the tail of the queue. The size of message that is copied to the tail node is returned. The number of bytes copied depends on the amount of bytes needed to make the tail node consistent. More...

CORBA::ULong queue_length (void)
 Return the length of the queue.. More...

int is_tail_fragmented (void)
 Check to see if the message at the tail (complete or incomplete) is a GIOP Fragment. More...

size_t missing_data_tail (void) const
 Return the size of data that is missing in tail of the queue. More...

TAO_Queued_Datafind_fragment (CORBA::Octet major, CORBA::Octet minor) const
 void missing_data (size_t data); Find the first fragment that matches the GIOP version. More...

TAO_Queued_Datafind_fragment (CORBA::ULong request_id) const
 Find the first fragment that matches the request id. More...

Node Inspection Predicates
These methods allow inspection of head and tail nodes for "completeness".

These methods check to see whether the node on the head or tail is "complete" and ready for further processing. See each method's documentation for its definition of "complete".

int is_tail_complete (void)
int is_head_complete (void)

Private Attributes

TAO_Queued_Datalast_added_
 A circular linked list of messages awaiting processing. More...

CORBA::ULong size_
 The size of the queue. More...

TAO_ORB_Coreorb_core_
 Copy of our ORB Core. More...


Friends

class TAO_Transport

Detailed Description

A queue of the messages in the incoming data path.

Please read the documentation in the TAO_Transport class to find out more about the design of the incoming data path.

Under certain conditions TAO may have to maintain a queue per-connection. This queue is drained by the pluggable protocols framework, normally under control of the ACE_Reactor, but other configurations are conceivable.

The memory that is allocated for holding the messages comes from the global pool for the following reasons

Definition at line 53 of file Incoming_Message_Queue.h.


Constructor & Destructor Documentation

TAO_Incoming_Message_Queue::TAO_Incoming_Message_Queue TAO_ORB_Core   orb_core
 

Constructor.

Definition at line 15 of file Incoming_Message_Queue.cpp.

00016   : last_added_ (0),
00017     size_ (0),
00018     orb_core_ (orb_core)
00019 {
00020 }

TAO_Incoming_Message_Queue::~TAO_Incoming_Message_Queue void   
 

Destructor.

Definition at line 22 of file Incoming_Message_Queue.cpp.

References dequeue_head, TAO_Queued_Data::release, and size_.

00023 {
00024   int sz = this->size_;
00025 
00026   // Delete all the nodes left behind
00027   for (int i = 0;
00028        i < sz;
00029        i++)
00030     {
00031       TAO_Queued_Data *qd = this->dequeue_head ();
00032       TAO_Queued_Data::release (qd);
00033     }
00034 }


Member Function Documentation

size_t TAO_Incoming_Message_Queue::copy_tail ACE_Message_Block   block
 

Copy message from <block> to the tail of the queue. The size of message that is copied to the tail node is returned. The number of bytes copied depends on the amount of bytes needed to make the tail node consistent.

Definition at line 37 of file Incoming_Message_Queue.cpp.

References ACE_Message_Block::copy, last_added_, ACE_Message_Block::length, TAO_Queued_Data::missing_data_bytes_, TAO_Queued_Data::msg_block_, ACE_Message_Block::rd_ptr, and size_.

00038 {
00039   // The size of message that is copied
00040   size_t n = 0;
00041 
00042   if (this->size_ > 0)
00043     {
00044       // Check to see if the length of the incoming block is less than
00045       // that of the <missing_data_> of the tail.
00046       if (block.length () <= this->last_added_->missing_data_bytes_)
00047         {
00048           n = block.length ();
00049         }
00050       else
00051         {
00052           n = this->last_added_->missing_data_bytes_;
00053         }
00054 
00055       // Do the copy
00056       this->last_added_->msg_block_->copy (block.rd_ptr (),
00057                                             n);
00058 
00059       // Decerement the missing data
00060       this->last_added_->missing_data_bytes_ -= n;
00061     }
00062 
00063   return n;
00064 }

TAO_Queued_Data * TAO_Incoming_Message_Queue::dequeue_head void   
 

Adding and deleting a node from the queue.

Definition at line 67 of file Incoming_Message_Queue.cpp.

References last_added_, TAO_Queued_Data::next_, and size_.

Referenced by TAO_Transport::process_queue_head, and ~TAO_Incoming_Message_Queue.

00068 {
00069   if (this->size_ == 0)
00070     return 0;
00071 
00072   // Get the node on the head of the queue...
00073   TAO_Queued_Data *head = this->last_added_->next_;
00074 
00075   // Reset the head node..
00076   this->last_added_->next_ = head->next_;
00077   
00078   // Decrease the size and reset last_added_ if empty
00079   if (--this->size_ == 0)
00080     this->last_added_ = 0;
00081 
00082   return head;
00083 }

TAO_Queued_Data * TAO_Incoming_Message_Queue::dequeue_tail void   
 

Definition at line 86 of file Incoming_Message_Queue.cpp.

References last_added_, TAO_Queued_Data::next_, and size_.

00087 {
00088   // This is a bit painful stuff...
00089   if (this->size_ == 0)
00090     return 0;
00091 
00092   // Get the node on the head of the queue...
00093   TAO_Queued_Data *head =
00094     this->last_added_->next_;
00095 
00096   while (head->next_ != this->last_added_)
00097     {
00098       head = head->next_;
00099     }
00100 
00101   // Put the head in tmp.
00102   head->next_ = this->last_added_->next_;
00103 
00104   TAO_Queued_Data *ret_qd = this->last_added_;
00105 
00106   this->last_added_ = head;
00107 
00108   // Decrease the size
00109   if (--this->size_ == 0)
00110     this->last_added_ = 0;
00111 
00112  return ret_qd;
00113 }

int TAO_Incoming_Message_Queue::enqueue_tail TAO_Queued_Data   nd
 

Definition at line 116 of file Incoming_Message_Queue.cpp.

References last_added_, TAO_Queued_Data::next_, and size_.

Referenced by TAO_Transport::enqueue_incoming_message.

00117 {
00118   if (this->size_ == 0)
00119     {
00120       this->last_added_ = nd;
00121       this->last_added_->next_ = this->last_added_;
00122     }
00123   else
00124     {
00125       nd->next_ = this->last_added_->next_;
00126       this->last_added_->next_ = nd;
00127       this->last_added_ = nd;
00128     }
00129 
00130   ++ this->size_;
00131   return 0;
00132 }

TAO_Queued_Data * TAO_Incoming_Message_Queue::find_fragment CORBA::ULong    request_id const
 

Find the first fragment that matches the request id.

Definition at line 160 of file Incoming_Message_Queue.cpp.

References last_added_, TAO_Queued_Data::more_fragments_, TAO_Queued_Data::next_, and TAO_Queued_Data::request_id_.

00161 {
00162   TAO_Queued_Data *found = 0;
00163   if (this->last_added_ != 0)
00164     {
00165       TAO_Queued_Data *qd = this->last_added_->next_;
00166 
00167       do {
00168         if (qd->more_fragments_ && qd->request_id_ == request_id)
00169           {
00170             found = qd;
00171           }
00172         else
00173           {
00174             qd = qd->next_;
00175           }
00176       } while (found == 0 && qd != this->last_added_->next_);
00177     }
00178 
00179   return found;
00180 }

TAO_Queued_Data * TAO_Incoming_Message_Queue::find_fragment CORBA::Octet    major,
CORBA::Octet    minor
const
 

void missing_data (size_t data); Find the first fragment that matches the GIOP version.

Definition at line 135 of file Incoming_Message_Queue.cpp.

References last_added_, TAO_Queued_Data::major_version_, TAO_Queued_Data::minor_version_, TAO_Queued_Data::more_fragments_, and TAO_Queued_Data::next_.

Referenced by TAO_Transport::enqueue_incoming_message.

00137 {
00138   TAO_Queued_Data *found = 0;
00139   if (this->last_added_ != 0)
00140     {
00141       TAO_Queued_Data *qd = this->last_added_->next_;
00142 
00143       do {
00144         if (qd->more_fragments_ &&
00145             qd->major_version_ == major && qd->minor_version_ == minor)
00146           {
00147             found = qd;
00148           }
00149         else
00150           {
00151             qd = qd->next_;
00152           }
00153       } while (found == 0 && qd != this->last_added_->next_);
00154     }
00155 
00156   return found;
00157 }

ACE_INLINE int TAO_Incoming_Message_Queue::is_head_complete void   
 

"complete" == the GIOP message at the head is not missing any data AND, if it's the first message in a series of GIOP fragments, all the fragments have been received, parsed, and placed into the queue

Returns:
-1 if queue is empty 0 if head is not "complete" 1 if head is "complete"

Definition at line 28 of file Incoming_Message_Queue.inl.

References last_added_, TAO_Queued_Data::missing_data_bytes_, TAO_Queued_Data::more_fragments_, TAO_Queued_Data::next_, and size_.

Referenced by TAO_Transport::process_queue_head.

00029 {
00030   if (this->size_ == 0)
00031     return -1;
00032 
00033   if (this->size_  &&
00034       this->last_added_->next_->missing_data_bytes_ == 0 &&
00035       this->last_added_->next_->more_fragments_ == 0)
00036     return 1;
00037 
00038   return 0;
00039 }

ACE_INLINE int TAO_Incoming_Message_Queue::is_tail_complete void   
 

"complete" == the GIOP message at the tail is not missing any data (it may be a complete GIOP Fragment, though)

Returns:
-1 queue is empty 0 tail is not "complete" 1 tail is "complete"

Definition at line 14 of file Incoming_Message_Queue.inl.

References last_added_, TAO_Queued_Data::missing_data_bytes_, and size_.

00015 {
00016   // If the size is 0 return -1
00017   if (this->size_ == 0)
00018     return -1;
00019 
00020   if (this->size_ &&
00021       this->last_added_->missing_data_bytes_ == 0)
00022     return 1;
00023 
00024   return 0;
00025 }

ACE_INLINE int TAO_Incoming_Message_Queue::is_tail_fragmented void   
 

Check to see if the message at the tail (complete or incomplete) is a GIOP Fragment.

Definition at line 42 of file Incoming_Message_Queue.inl.

References last_added_, TAO_Queued_Data::more_fragments_, and size_.

00043 {
00044   if (this->size_ == 0)
00045     return 0;
00046 
00047   if (this->size_  &&
00048       this->last_added_->more_fragments_ == 1)
00049     return 1;
00050 
00051   return 0;
00052 }

ACE_INLINE size_t TAO_Incoming_Message_Queue::missing_data_tail void    const
 

Return the size of data that is missing in tail of the queue.

Definition at line 55 of file Incoming_Message_Queue.inl.

References last_added_, TAO_Queued_Data::missing_data_bytes_, and size_.

00056 {
00057   if (this->size_ != 0)
00058     return this->last_added_->missing_data_bytes_;
00059 
00060   return 0;
00061 }

ACE_INLINE CORBA::ULong TAO_Incoming_Message_Queue::queue_length void   
 

Return the length of the queue..

Definition at line 8 of file Incoming_Message_Queue.inl.

References size_.

Referenced by TAO_Transport::handle_input_i, and TAO_Transport::process_queue_head.

00009 {
00010   return this->size_;
00011 }


Friends And Related Function Documentation

friend class TAO_Transport [friend]
 

Definition at line 128 of file Incoming_Message_Queue.h.


Member Data Documentation

TAO_Queued_Data* TAO_Incoming_Message_Queue::last_added_ [private]
 

A circular linked list of messages awaiting processing.

last_message_added_ points to the most recent message added to the list. The earliest addition can be easily accessed via last_message_added_->next_.

Definition at line 138 of file Incoming_Message_Queue.h.

Referenced by copy_tail, dequeue_head, dequeue_tail, enqueue_tail, find_fragment, is_head_complete, is_tail_complete, is_tail_fragmented, and missing_data_tail.

TAO_ORB_Core* TAO_Incoming_Message_Queue::orb_core_ [private]
 

Copy of our ORB Core.

Definition at line 144 of file Incoming_Message_Queue.h.

CORBA::ULong TAO_Incoming_Message_Queue::size_ [private]
 

The size of the queue.

Definition at line 141 of file Incoming_Message_Queue.h.

Referenced by copy_tail, dequeue_head, dequeue_tail, enqueue_tail, is_head_complete, is_tail_complete, is_tail_fragmented, missing_data_tail, queue_length, and ~TAO_Incoming_Message_Queue.


The documentation for this class was generated from the following files:
Generated on Mon Jun 16 15:21:42 2003 for TAO by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002