diff options
Diffstat (limited to 'TAO/tao/Queued_Message.h')
-rw-r--r-- | TAO/tao/Queued_Message.h | 98 |
1 files changed, 63 insertions, 35 deletions
diff --git a/TAO/tao/Queued_Message.h b/TAO/tao/Queued_Message.h index 25d4a018b9e..c9e6296c7d5 100644 --- a/TAO/tao/Queued_Message.h +++ b/TAO/tao/Queued_Message.h @@ -26,8 +26,8 @@ class TAO_Message_Sent_Callback; /** * @class TAO_Queued_Message * - * @brief Implement an queued message for the outgoing path in the - * TAO_Transport class + * @brief Represent messages queued in the outgoing data path of the + * TAO_Transport class. * * Please read the documentation in the TAO_Transport class to find * out more about the design of the outgoing data path. @@ -66,29 +66,15 @@ class TAO_Export TAO_Queued_Message public: /// Constructor /** - * @param contents The message block chain that must be sent. - * - * @param own_contents If this flag is true then this object assumes - * ownership of the contents. - * * @param callback A callback interface to signal any waiting * threads about the status of the message. It is null if there are * no waiting threads. */ - TAO_Queued_Message (ACE_Message_Block *contents, - int own_contents, - TAO_Message_Sent_Callback *callback = 0); + TAO_Queued_Message (TAO_Message_Sent_Callback *callback = 0); /// Destructor virtual ~TAO_Queued_Message (void); - /// Get the message block - ACE_Message_Block *mb (void) const; - - /// The transport has successfully sent more data, adjust internal - /// status - void bytes_transferred (size_t byte_count); - /// Return 0 if the message has not been completely sent int done (void) const; @@ -96,9 +82,6 @@ public: /// signal waiting threads. void connection_closed (void); - /// Reclaim resources - void destroy (void); - /** @name Intrusive list manipulation * * The messages are put in a doubled linked list (for easy insertion @@ -143,18 +126,70 @@ public: TAO_Queued_Message *&tail); //@} -private: - /// The contents of the message. + /** @name Template Methods + */ + //@{ + + /// Return the length of the message /** - * The message is normally generated by a TAO_OutputCDR stream. The - * application marshals the payload, possibly generating a chain of - * message block connected via the 'cont()' field. + * If the message has been partially sent it returns the number of + * bytes that are still not sent. */ - ACE_Message_Block *contents_; + virtual size_t message_length (void) const = 0; - /// If not zero the @c contents_ are owned by this object - int own_contents_; + /// Return 1 if all the data has been sent + virtual int all_data_sent (void) const = 0; + /// 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. + * + * @param iovcnt_max The number of elements in iov + * @param iovcnt The number of elements already used by iov, this + * method should update this counter + * @param iov The io vector + */ + virtual void fill_iov (int iovcnt_max, int &iovcnt, iovec iov[]) const = 0; + + /// 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. + * + * @param 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. + * @return Returns 1 if the TAO_Queued_Message has any more data to + * send. + */ + virtual int bytes_transferred (size_t &byte_count) = 0; + + /// 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. + */ + virtual void destroy (void) = 0; + //@} + +protected: + /// Record if the send was completely successful + int data_sent_successfully_; + + /// Set to 1 if the connection was closed + int connection_closed_; + +private: /// If not null, this is the object that we signal to indicate that /// the message was sent. /** @@ -163,13 +198,6 @@ private: */ TAO_Message_Sent_Callback *callback_; - /// The current message block - /** - * The message may be set in multiple writev() operations. This - * point keeps track of the next message to send out. - */ - ACE_Message_Block *current_block_; - /// Implement an intrusive double-linked list for the message queue TAO_Queued_Message *next_; TAO_Queued_Message *prev_; |