diff options
Diffstat (limited to 'TAO/tao/Sync_Strategies.h')
-rw-r--r-- | TAO/tao/Sync_Strategies.h | 92 |
1 files changed, 68 insertions, 24 deletions
diff --git a/TAO/tao/Sync_Strategies.h b/TAO/tao/Sync_Strategies.h index 5b273dac3e5..b5f2ae4b2ee 100644 --- a/TAO/tao/Sync_Strategies.h +++ b/TAO/tao/Sync_Strategies.h @@ -27,24 +27,57 @@ #include "tao/Transport.h" #include "tao/TAOC.h" +/// Define the interface for the Queueing Strategy +/** + * The low-level I/O components in the ORB use this strategy to + * determine when messages must be queued, immediately sent or + * flushed. + * + * The strategy isolates this low-level components from the higher + * level strategies used by the application developer. + * + * @todo The class name (Sync_Strategy) is inherited from the policies + * (SyncScopePolicy), but Queueing_Strategy probably captures its + * intent better. It should be changed in a future revision of the + * ORB. + */ class TAO_Export TAO_Sync_Strategy { public: + /// Destructor virtual ~TAO_Sync_Strategy (void); - virtual ssize_t send (TAO_Transport &transport, - TAO_Stub &stub, - const ACE_Message_Block *message_block, - const ACE_Time_Value *max_wait_time) = 0; + /// Return 1 if a message must be queued + virtual int must_queue (int queue_empty) = 0; + + /// Return 1 if it is time to start + /** + * @param stub The object used to make the request, this is used to + * obtain the policies currently in effect for the request + * @param msg_count The number of messages currently queued + * @param total_bytes Number of bytes currently queued + * @param set_timer Returns 1 if a timer should be set to drain the + * queue + * @param interval If set_timer returns 1, this parameter contains + * the timer interval + */ + virtual int buffering_constraints_reached (TAO_Stub *stub, + size_t msg_count, + size_t total_bytes, + int &set_timer, + ACE_Time_Value &interval) = 0; }; class TAO_Export TAO_Transport_Sync_Strategy : public TAO_Sync_Strategy { public: - ssize_t send (TAO_Transport &transport, - TAO_Stub &stub, - const ACE_Message_Block *message_block, - const ACE_Time_Value *max_wait_time); + virtual int must_queue (int queue_empty); + + virtual int buffering_constraints_reached (TAO_Stub *stub, + size_t msg_count, + size_t total_bytes, + int &set_timer, + ACE_Time_Value &interval); }; #if (TAO_HAS_BUFFERING_CONSTRAINT_POLICY == 1) @@ -52,28 +85,39 @@ public: class TAO_Export TAO_Eager_Buffering_Sync_Strategy : public TAO_Sync_Strategy { public: - ssize_t send (TAO_Transport &transport, - TAO_Stub &stub, - const ACE_Message_Block *message_block, - const ACE_Time_Value *max_wait_time); - - virtual int buffering_constraints_reached (TAO_Transport &transport, - TAO_Stub &stub, - TAO_Transport_Buffering_Queue &buffering_queue); - - void timer_check (TAO_Transport &transport, - const TAO::BufferingConstraint &buffering_constraint); - + virtual int must_queue (int queue_empty); + + virtual int buffering_constraints_reached (TAO_Stub *stub, + size_t msg_count, + size_t total_bytes, + int &set_timer, + ACE_Time_Value &interval); + +private: + /// Check if the buffering constraint includes any timeouts and + /// compute the right timeout interval if needed. + /** + * @param buffering_constraint The constraints defined by the + * application + * @param set_timer Return 1 if the timer should be set + * @param interval Return the timer interval value + */ + void timer_check (const TAO::BufferingConstraint &buffering_constraint, + int &set_timer, + ACE_Time_Value &interval); + + /// Convert from standard CORBA time units to seconds/microseconds. ACE_Time_Value time_conversion (const TimeBase::TimeT &time); }; +/// Delay the buffering decision until the transport blocks +/** + * If the queue is empty the transport will try to send immediately. + */ class TAO_Export TAO_Delayed_Buffering_Sync_Strategy : public TAO_Eager_Buffering_Sync_Strategy { public: - ssize_t send (TAO_Transport &transport, - TAO_Stub &stub, - const ACE_Message_Block *message_block, - const ACE_Time_Value *max_wait_time); + virtual int must_queue (int queue_empty); }; #endif /* TAO_HAS_BUFFERING_CONSTRAINT_POLICY == 1 */ |