Revert "Use a variable on the stack to not have a temporary in the call"
[ACE_TAO.git] / TAO / tao / Synch_Queued_Message.h
blob78f4622e3274c0abe6edd2adb926edc9408422aa
1 // -*- C++ -*-
3 //=============================================================================
4 /**
5 * @file Synch_Queued_Message.h
7 * @author Carlos O'Ryan <coryan@uci.edu>
8 */
9 //=============================================================================
11 #ifndef TAO_SYNCH_QUEUED_MESSAGE_H
12 #define TAO_SYNCH_QUEUED_MESSAGE_H
14 #include /**/ "ace/pre.h"
16 #include "tao/Queued_Message.h"
18 #if !defined (ACE_LACKS_PRAGMA_ONCE)
19 # pragma once
20 #endif /* ACE_LACKS_PRAGMA_ONCE */
22 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
24 /**
25 * @class TAO_Synch_Queued_Message
27 * @brief Specialize TAO_Queued_Message for synchronous requests,
28 * i.e. twoways and oneways sent with reliability better than
29 * SYNC_NONE.
31 * Reliable requests block the sending thread until the message is
32 * sent, likewise, the sending thread must be informed if the
33 * connection is closed or the message times out.
35 * In contrast oneway (and AMI) requests sent with the SYNC_NONE
36 * policy are simple discarded if the connection fails or they
37 * timeout.
39 * Another important difference is the management of the data buffer:
40 * one SYNC_NONE messages the buffer is immediately copied into a
41 * newly allocated buffer, and must be deallocated. Other types of
42 * requests use the memory allocated by the sending thread.
44 class TAO_Export TAO_Synch_Queued_Message : public TAO_Queued_Message
46 public:
47 /// Constructor
48 /**
49 * @param contents The message block chain that must be sent.
51 * @param alloc The allocator that is used to allocate objects of
52 * this type.
54 TAO_Synch_Queued_Message (const ACE_Message_Block *contents,
55 TAO_ORB_Core *oc,
56 ACE_Allocator *alloc = 0,
57 bool is_heap_allocated = false);
59 /// Destructor
60 virtual ~TAO_Synch_Queued_Message ();
62 const ACE_Message_Block *current_block () const;
64 /** @name Implement the Template Methods from TAO_Queued_Message
66 //@{
67 virtual size_t message_length () const;
68 virtual int all_data_sent () const;
69 virtual void fill_iov (int iovcnt_max, int &iovcnt, iovec iov[]) const;
70 virtual void bytes_transferred (size_t &byte_count);
71 virtual TAO_Queued_Message *clone (ACE_Allocator *alloc);
72 virtual void destroy ();
73 virtual void copy_if_necessary (const ACE_Message_Block* chain);
74 //@}
76 private:
77 /// The contents of the message.
78 /**
79 * The message is normally generated by a TAO_OutputCDR stream. The
80 * application marshals the payload, possibly generating a chain of
81 * message block connected via the 'cont()' field.
83 ACE_Message_Block *contents_;
85 /// The current message block
86 /**
87 * The message may be set in multiple writev() operations. This
88 * point keeps track of the next message to send out.
90 ACE_Message_Block *current_block_;
92 /// Do we own the contents_ message block?
93 /**
94 * This flag differs from the is_heap_allocated_ flag in that it only
95 * applies to the contents_ message block and not the
96 * TAO_Synch_Queued_Message object itself.
98 bool own_contents_;
101 TAO_END_VERSIONED_NAMESPACE_DECL
103 #include /**/ "ace/post.h"
105 #endif /* TAO_QUEUED_MESSAGE_H */