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

RMCast_Membership.h

Go to the documentation of this file.
00001 /* -*- C++ -*- */
00002 // $Id: RMCast_Membership.h,v 1.1.1.1 2001/12/04 14:33:17 chad Exp $
00003 
00004 // ============================================================================
00005 //
00006 // = LIBRARY
00007 //    ace
00008 //
00009 // = FILENAME
00010 //    RMCast_Membership.h
00011 //
00012 // = AUTHOR
00013 //    Carlos O'Ryan <coryan@uci.edu>
00014 //
00015 // ============================================================================
00016 
00017 #ifndef ACE_RMCAST_MEMBERSHIP_H
00018 #define ACE_RMCAST_MEMBERSHIP_H
00019 #include "ace/pre.h"
00020 
00021 #include "RMCast_Module.h"
00022 #include "ace/Containers.h"
00023 #include "ace/Synch.h"
00024 
00025 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00026 # pragma once
00027 #endif /* ACE_LACKS_PRAGMA_ONCE */
00028 
00029 class ACE_RMCast_Proxy;
00030 
00031 /// Track peer membership
00032 /**
00033  * Reliable senders of events need to know exactly how many peers are
00034  * receiving the events, and how many events has each peer received so
00035  * far.
00036  * This class uses the Join, Leave and Ack messages to build that
00037  * information, it also summarizes the Ack events and propagate only
00038  * the global info to the upper layer.
00039  */
00040 class ACE_RMCast_Export ACE_RMCast_Membership : public ACE_RMCast_Module
00041 {
00042 public:
00043   /// Constructor
00044   ACE_RMCast_Membership (void);
00045 
00046   /// Destructor
00047   virtual ~ACE_RMCast_Membership (void);
00048 
00049   /// Return 1 if there are still members in the group
00050   int has_members (void);
00051 
00052   /// Receive an process an Ack message
00053   /**
00054    * After receiving the Ack message we find out what is the lowest
00055    * sequence number received in order among all the acks received by
00056    * the proxies in the collection. We also find out what is the
00057    * highest sequence number received by any proxy.
00058    * We only propagate that information back to the upper layer, and
00059    * then only if there are any news since the last Ack.
00060    */
00061   virtual int ack (ACE_RMCast::Ack &);
00062 
00063   /// Add a new member to the collection, using the <source> field in
00064   /// the Join message
00065   virtual int join (ACE_RMCast::Join &);
00066 
00067   /// Remove a member from the collection, using the <source> field in
00068   /// the Join message
00069   virtual int leave (ACE_RMCast::Leave &);
00070 
00071 private:
00072   /// Generate an Ack message, normally due to changes in the
00073   /// collection, such as new proxys joining or leaving
00074   int generate_ack (ACE_RMCast_Proxy *proxy);
00075 
00076   /// Compute an Ack message to propagate to the upper layers.
00077   int compute_ack_i (ACE_RMCast_Proxy *source,
00078                      ACE_RMCast::Ack &next_ack);
00079 
00080 protected:
00081   /// Use an unbounded set to maintain the collection of proxies.
00082   typedef ACE_Unbounded_Set<ACE_RMCast_Proxy*> Proxy_Collection;
00083   typedef ACE_Unbounded_Set_Iterator<ACE_RMCast_Proxy*> Proxy_Iterator;
00084 
00085   /// The collection of proxies
00086   Proxy_Collection proxies_;
00087 
00088   /// The smallest value of \param next_expected for all the proxies
00089   ACE_UINT32 next_expected_;
00090 
00091   /// The highest value of \param highest_received for all the proxies
00092   ACE_UINT32 highest_received_;
00093 
00094   /// Synchronization
00095   ACE_SYNCH_MUTEX mutex_;
00096 };
00097 
00098 #if defined (__ACE_INLINE__)
00099 #include "RMCast_Membership.i"
00100 #endif /* __ACE_INLINE__ */
00101 
00102 #include "ace/post.h"
00103 #endif /* ACE_RMCAST_MEMBERSHIP_H */

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