Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

RMCast_Reordering.h

Go to the documentation of this file.
00001 /* -*- C++ -*- */
00002 // $Id: RMCast_Reordering.h,v 1.1.1.1 2001/12/04 14:33:17 chad Exp $
00003 
00004 // ============================================================================
00005 //
00006 // = LIBRARY
00007 //    ace/RMCast
00008 //
00009 // = AUTHOR
00010 //    Carlos O'Ryan <coryan@uci.edu>
00011 //
00012 // ============================================================================
00013 
00014 #ifndef ACE_RMCAST_REORDERING_H
00015 #define ACE_RMCAST_REORDERING_H
00016 #include "ace/pre.h"
00017 
00018 #include "RMCast_Module.h"
00019 #include "ace/RB_Tree.h"
00020 #include "ace/Synch.h"
00021 
00022 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00023 # pragma once
00024 #endif /* ACE_LACKS_PRAGMA_ONCE */
00025 
00026 class ACE_RMCast_Proxy;
00027 
00028 /// Pass messages up in sent order
00029 /**
00030  * Some applications require receivers to process messages in the same
00031  * order that messages are sent.  This module buffers out of order
00032  * messages and only delivers a message if:
00033  * - All the previous messages have been delivered.
00034  * - The sender sends a notification that previous messages will not
00035  *   be resent.
00036  *
00037  * The module also sends the Ack feedback to the sender.
00038  *
00039  * NOTE:  This is not the same as causal or total ordering, that could
00040  * be implemented someday, but requires a lot more than what we have
00041  * right now.
00042  *
00043  */
00044 class ACE_RMCast_Export ACE_RMCast_Reordering : public ACE_RMCast_Module
00045 {
00046 public:
00047   /// Constructor
00048   ACE_RMCast_Reordering (void);
00049 
00050   /// Destructor
00051   virtual ~ACE_RMCast_Reordering (void);
00052 
00053   /// Use a Red-Black Tree to keep the queue of messages
00054   //@{
00055   typedef ACE_RB_Tree<ACE_UINT32,ACE_RMCast::Data,ACE_Less_Than<ACE_UINT32>,ACE_Null_Mutex> Messages;
00056   typedef ACE_RB_Tree_Iterator<ACE_UINT32,ACE_RMCast::Data,ACE_Less_Than<ACE_UINT32>,ACE_Null_Mutex> Messages_Iterator;
00057   //@}
00058 
00059   /// Remove messages still pending
00060   virtual int close (void);
00061 
00062   /// Process a Data message.
00063   /**
00064    * Process a Data message, sending the right Ack message back.
00065    * The message is passed up only if it is in order.
00066    */
00067   virtual int data (ACE_RMCast::Data &);
00068 
00069   /// During the join process the server informs us of the next
00070   /// expected message
00071   virtual int ack_join (ACE_RMCast::Ack_Join &);
00072 
00073 private:
00074   /// Push any messages that are pending in the queue
00075   int push_queued_messages (void);
00076 
00077 protected:
00078   /// The reordering buffer
00079   Messages messages_;
00080 
00081   /// The smallest value of \param next_expected for all the proxies
00082   ACE_UINT32 next_expected_;
00083 
00084   /// The highest value of \param highest_received for all the proxies
00085   ACE_UINT32 highest_received_;
00086 
00087   /// Synchronization
00088   ACE_SYNCH_MUTEX mutex_;
00089 };
00090 
00091 #if defined (__ACE_INLINE__)
00092 #include "RMCast_Reordering.i"
00093 #endif /* __ACE_INLINE__ */
00094 
00095 #include "ace/post.h"
00096 #endif /* ACE_RMCAST_REORDERING_H */

Generated on Mon Jun 16 13:12:37 2003 for ACE_RMCast by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002