[asterisk-scf-commits] asterisk-scf/integration/ice-util-cpp.git branch "route_replica" updated.

Commits to the Asterisk SCF project code repositories asterisk-scf-commits at lists.digium.com
Wed May 4 12:24:18 CDT 2011


branch "route_replica" has been updated
       via  3d88e4b36b73e42bd41b33dc506a3d6a031e99bb (commit)
      from  a0a5f342325fd92ec12071e44fce1d67310c99e1 (commit)

Summary of changes:
 .../include/AsteriskSCF/StateReplicator.h          |   58 +++++++++-----------
 1 files changed, 25 insertions(+), 33 deletions(-)


- Log -----------------------------------------------------------------
commit 3d88e4b36b73e42bd41b33dc506a3d6a031e99bb
Author: Ken Hunt <ken.hunt at digium.com>
Date:   Wed May 4 12:16:13 2011 -0500

    Backed out the conversion of listener proxies to oneways. Incorporated review feedback.

diff --git a/StateReplicator/include/AsteriskSCF/StateReplicator.h b/StateReplicator/include/AsteriskSCF/StateReplicator.h
index 8cfd691..0186142 100644
--- a/StateReplicator/include/AsteriskSCF/StateReplicator.h
+++ b/StateReplicator/include/AsteriskSCF/StateReplicator.h
@@ -30,8 +30,8 @@ namespace StateReplication
  * of the fields from the order in which they were added to the collection. If an item is removed and
  * re-added later, it goes to the back of the list.
  *  - The state item type is assumed to have a public field named "key" which is of type "K".
-
- The Replicator should implement (at a minimum) these operations:
+ *
+  The Replicator should implement (at a minimum) these operations:
  interface FooStateReplicator
  {
  void addListener(TestStateReplicatorListener *listener);
@@ -53,6 +53,8 @@ namespace StateReplication
 
  * NOTE: - The process should be made asynchronous.
  * NOTE: - Should probably use IceStorm for forwarding to all listeners.
+ * One-way proxies can be passed in as listeners, but this may alter the order
+ * in which updates are received by the listener.
  */
 template<typename R, typename S, typename K, typename L>
 class StateReplicator : public R
@@ -68,18 +70,18 @@ public:
     public:
         SetStateNotice(const U& stateSeq) : mStateSeq(stateSeq) {}
         ~SetStateNotice() {}
-        void operator() (T x)
+        void operator() (const T& x)
         {
             try
             {
-                T listenerOneWay = T::uncheckedCast(x->ice_oneway());
-                listenerOneWay->stateSet(mStateSeq);
-            }
-            catch(const Ice::Exception&)
-            {
+                x->stateSet(mStateSeq);
             }
             catch(...)
             {
+                // For now we're silently consuming exceptions to 
+                // insure all listeners are notified. Future efforts
+                // in creating a robust state replication back-end 
+                // should at the very least log these exceptions.
             }
         }
         U mStateSeq;
@@ -94,18 +96,18 @@ public:
     public:
         RemoveStateByKeyNotice(const V& keys) : mKeys(keys) {}
         ~RemoveStateByKeyNotice() {}
-        void operator() (T x)
+        void operator() (const T& x)
         {
             try
             {
-                T listenerOneWay = T::uncheckedCast(x->ice_oneway());
-                listenerOneWay->stateRemoved(mKeys);
-            }
-            catch(const Ice::Exception&)
-            {
+                x->stateRemoved(mKeys);
             }
             catch(...)
             {
+                // For now we're silently consuming exceptions to 
+                // insure all listeners are notified. Future efforts
+                // in creating a robust state replication back-end 
+                // should at the very least log these exceptions.
             }
         }
         V mKeys;
@@ -124,14 +126,14 @@ public:
         {
             try
             {
-                T listenerOneWay = T::uncheckedCast(x->ice_oneway());
-                listenerOneWay->stateRemovedForItems(mStateSeq);
-            }
-            catch(const Ice::Exception&)
-            {
+                x->stateRemovedForItems(mStateSeq);
             }
             catch(...)
             {
+                // For now we're silently consuming exceptions to 
+                // insure all listeners are notified. Future efforts
+                // in creating a robust state replication back-end 
+                // should at the very least log these exceptions.
             }
         }
         U mStateSeq;
@@ -145,7 +147,7 @@ public:
     public:
         IdentifyListener(const T& listener) : mListener(listener) {}
         ~IdentifyListener() {}
-        bool operator() (T x) {return (x->ice_getIdentity() == mListener->ice_getIdentity());}
+        bool operator() (const T& x) {return (x->ice_getIdentity() == mListener->ice_getIdentity());}
         T mListener;
     };
 
@@ -154,7 +156,7 @@ public:
     public:
         MatchItem(const D& key) : mKey(key) {}
         ~MatchItem() {}
-        bool operator() (T x) {return (x->key == mKey); }
+        bool operator() (const T& x) {return (x->key == mKey); }
         D mKey;
     };
 
@@ -173,19 +175,9 @@ public:
             mListeners.push_back(listener);
         }
 
-        // Give this listener the current state.
+        // Give this new listener the current state.
         boost::shared_lock<boost::shared_mutex> lock(mStateLock);
-        try
-        {
-            L listenerOneWay = L::uncheckedCast(listener->ice_oneway());
-            listenerOneWay->stateSet(mStateItems);
-        }
-        catch(const Ice::Exception&)
-        {
-        }
-        catch(...)
-        {
-        }
+        listener->stateSet(mStateItems);
     }
 
     /**

-----------------------------------------------------------------------


-- 
asterisk-scf/integration/ice-util-cpp.git



More information about the asterisk-scf-commits mailing list