#include <Queued_Message.h>
Inheritance diagram for TAO_Queued_Message:
Public Member Functions | |
TAO_Queued_Message (TAO_ORB_Core *oc, ACE_Allocator *alloc=0, bool is_heap_allocated=false) | |
Constructor. | |
virtual | ~TAO_Queued_Message (void) |
Destructor. | |
Intrusive list manipulation | |
The messages are put in a doubled linked list (for easy insertion and removal). To minimize memory allocations the list is intrusive, i.e. each element in the list contains the pointers for the next and previous element. The following methods are used to manipulate this implicit list.
| |
TAO_Queued_Message * | next (void) const |
Set/get the next element in the list. | |
TAO_Queued_Message * | prev (void) const |
Set/get the previous element in the list. | |
void | remove_from_list (TAO_Queued_Message *&head, TAO_Queued_Message *&tail) |
Remove this element from the list. | |
void | push_back (TAO_Queued_Message *&head, TAO_Queued_Message *&tail) |
Insert the current element at the tail of the queue. | |
void | push_front (TAO_Queued_Message *&head, TAO_Queued_Message *&tail) |
Insert the current element at the head of the queue. | |
Template Methods | |
virtual size_t | message_length (void) const =0 |
Return the length of the message. | |
virtual int | all_data_sent (void) const =0 |
Return 1 if all the data has been sent. | |
virtual void | fill_iov (int iovcnt_max, int &iovcnt, iovec iov[]) const =0 |
Fill up an io vector using the connects of the message. | |
virtual void | bytes_transferred (size_t &byte_count)=0 |
Update the internal state, data has been sent. | |
virtual TAO_Queued_Message * | clone (ACE_Allocator *allocator)=0 |
Clone this element. | |
virtual void | destroy (void)=0 |
Reclaim resources. | |
virtual bool | is_expired (const ACE_Time_Value &now) const |
Check for timeout. | |
Protected Attributes | |
ACE_Allocator * | allocator_ |
bool const | is_heap_created_ |
TAO_ORB_Core * | orb_core_ |
Cached copy of ORB_Core pointer. | |
Private Attributes | |
TAO_Queued_Message * | next_ |
Implement an intrusive double-linked list for the message queue. | |
TAO_Queued_Message * | prev_ |
Please read the documentation in the TAO_Transport class to find out more about the design of the outgoing data path.
In some configurations TAO needs to maintain a per-connection queue of outgoing messages. This queue is drained by the pluggable protocols framework, normally under control of the ACE_Reactor, but other configurations are conceivable. The elements in the queue may be removed early, for example, because the application can specify timeouts for each message, or because the underlying connection is broken.
In many cases the message corresponds to some application request, the application may be blocked waiting for the request to be sent, even more importantlyl, the ORB can be configured to use the Leader/Followers strategy, in which case one of the waiting threads can be required to wake up before its message completes each message may contain a 'Sent_Notifier'
The contents of the ACE_Message_Block may have been allocated from TSS storage, in that case we cannot steal them. However, we do not need to perform a deep copy all the time, for example, in a twoway request the sending thread blocks until the data goes out. The queued message can borrow the memory as it will be deallocated by the sending thread when it finishes. Oneways and asynchronous calls are another story.
Definition at line 75 of file Queued_Message.h.
TAO_BEGIN_VERSIONED_NAMESPACE_DECL TAO_Queued_Message::TAO_Queued_Message | ( | TAO_ORB_Core * | oc, | |
ACE_Allocator * | alloc = 0 , |
|||
bool | is_heap_allocated = false | |||
) |
Constructor.
Definition at line 15 of file Queued_Message.cpp.
00018 : allocator_ (alloc) 00019 , is_heap_created_ (is_heap_allocated) 00020 , orb_core_ (oc) 00021 , next_ (0) 00022 , prev_ (0) 00023 { 00024 }
TAO_Queued_Message::~TAO_Queued_Message | ( | void | ) | [virtual] |
virtual int TAO_Queued_Message::all_data_sent | ( | void | ) | const [pure virtual] |
Return 1 if all the data has been sent.
Implemented in TAO_Asynch_Queued_Message, and TAO_Synch_Queued_Message.
Referenced by TAO_Transport::cleanup_queue(), TAO_Reactive_Flushing_Strategy::flush_message(), and TAO_Block_Flushing_Strategy::flush_message().
virtual void TAO_Queued_Message::bytes_transferred | ( | size_t & | byte_count | ) | [pure virtual] |
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.
byte_count | The number of bytes succesfully sent. The TAO_Queued_Message should decrement this value by the number of bytes that must still be sent. |
Implemented in TAO_Asynch_Queued_Message, and TAO_Synch_Queued_Message.
Referenced by TAO_Transport::cleanup_queue().
virtual TAO_Queued_Message* TAO_Queued_Message::clone | ( | ACE_Allocator * | allocator | ) | [pure virtual] |
virtual void TAO_Queued_Message::destroy | ( | void | ) | [pure virtual] |
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.
Implemented in TAO_Asynch_Queued_Message, and TAO_Synch_Queued_Message.
Referenced by TAO_Transport::cleanup_queue(), TAO_Transport::cleanup_queue_i(), TAO_Transport::drain_queue_i(), and TAO_Transport::send_reply_message_i().
virtual void TAO_Queued_Message::fill_iov | ( | int | iovcnt_max, | |
int & | iovcnt, | |||
iovec | iov[] | |||
) | const [pure virtual] |
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.
iovcnt_max | The number of elements in iov | |
iovcnt | The number of elements already used by iov, this method should update this counter | |
iov | The io vector |
Implemented in TAO_Asynch_Queued_Message, and TAO_Synch_Queued_Message.
Referenced by TAO_Transport::drain_queue_i().
bool TAO_Queued_Message::is_expired | ( | const ACE_Time_Value & | now | ) | const [virtual] |
Check for timeout.
now | Pass in the current time using ACE_High_Res_Timer::gettimeofday_hr(). This is a parameter in order to avoid calling gettimeofday_hr() inside of this method (which will be called in a tight loop). |
Reimplemented in TAO_Asynch_Queued_Message.
Definition at line 97 of file Queued_Message.cpp.
Referenced by TAO_Transport::drain_queue_i().
virtual size_t TAO_Queued_Message::message_length | ( | void | ) | const [pure virtual] |
Return the length of the message.
If the message has been partially sent it returns the number of bytes that are still not sent.
Implemented in TAO_Asynch_Queued_Message, and TAO_Synch_Queued_Message.
Referenced by TAO_Transport::cleanup_queue(), and TAO_Transport::cleanup_queue_i().
TAO_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE TAO_Queued_Message * TAO_Queued_Message::next | ( | void | ) | const |
Set/get the next element in the list.
Definition at line 6 of file Queued_Message.inl.
References next_.
Referenced by TAO_Transport::drain_queue_i().
00007 { 00008 return this->next_; 00009 }
ACE_INLINE TAO_Queued_Message * TAO_Queued_Message::prev | ( | void | ) | const |
Set/get the previous element in the list.
Definition at line 12 of file Queued_Message.inl.
References prev_.
00013 { 00014 return this->prev_; 00015 }
void TAO_Queued_Message::push_back | ( | TAO_Queued_Message *& | head, | |
TAO_Queued_Message *& | tail | |||
) |
Insert the current element at the tail of the queue.
Definition at line 57 of file Queued_Message.cpp.
Referenced by TAO_Transport::queue_message_i(), TAO_Transport::send_message_block_chain_i(), TAO_Transport::send_reply_message_i(), and TAO_Transport::send_synchronous_message_i().
00059 { 00060 if (tail == 0) 00061 { 00062 tail = this; 00063 head = this; 00064 this->next_ = 0; 00065 this->prev_ = 0; 00066 } 00067 else 00068 { 00069 tail->next_ = this; 00070 this->prev_ = tail; 00071 this->next_ = 0; 00072 tail = this; 00073 } 00074 }
void TAO_Queued_Message::push_front | ( | TAO_Queued_Message *& | head, | |
TAO_Queued_Message *& | tail | |||
) |
Insert the current element at the head of the queue.
Definition at line 77 of file Queued_Message.cpp.
Referenced by TAO_Transport::queue_message_i().
00079 { 00080 if (head == 0) 00081 { 00082 tail = this; 00083 head = this; 00084 this->next_ = 0; 00085 this->prev_ = 0; 00086 } 00087 else 00088 { 00089 head->prev_ = this; 00090 this->next_ = head; 00091 this->prev_ = 0; 00092 head = this; 00093 } 00094 }
void TAO_Queued_Message::remove_from_list | ( | TAO_Queued_Message *& | head, | |
TAO_Queued_Message *& | tail | |||
) |
Remove this element from the list.
Definition at line 31 of file Queued_Message.cpp.
Referenced by TAO_Transport::cleanup_queue(), TAO_Transport::cleanup_queue_i(), TAO_Transport::drain_queue_i(), TAO_Transport::send_message_block_chain_i(), TAO_Transport::send_reply_message_i(), TAO_Transport::send_synch_message_helper_i(), and TAO_Transport::send_synchronous_message_i().
00033 { 00034 if (this->prev_ != 0) 00035 { 00036 this->prev_->next_ = this->next_; 00037 } 00038 else if(head == this) 00039 { 00040 head = this->next_; 00041 } 00042 00043 if (this->next_ != 0) 00044 { 00045 this->next_->prev_ = this->prev_; 00046 } 00047 else if(tail == this) 00048 { 00049 tail = this->prev_; 00050 } 00051 00052 this->next_ = 0; 00053 this->prev_ = 0; 00054 }
ACE_Allocator* TAO_Queued_Message::allocator_ [protected] |
Definition at line 215 of file Queued_Message.h.
bool const TAO_Queued_Message::is_heap_created_ [protected] |
Definition at line 221 of file Queued_Message.h.
TAO_Queued_Message* TAO_Queued_Message::next_ [private] |
Implement an intrusive double-linked list for the message queue.
Definition at line 228 of file Queued_Message.h.
Referenced by next(), push_back(), push_front(), and remove_from_list().
TAO_ORB_Core* TAO_Queued_Message::orb_core_ [protected] |
TAO_Queued_Message* TAO_Queued_Message::prev_ [private] |
Definition at line 229 of file Queued_Message.h.
Referenced by prev(), push_back(), push_front(), and remove_from_list().