Author: gsim
Date: Thu May 29 05:03:26 2008
New Revision: 661309

URL: http://svn.apache.org/viewvc?rev=661309&view=rev
Log:
Move AckPolicy impl from header to .cpp; ensure that completion is marked even 
when auto-acking is turned off.


Added:
    incubator/qpid/trunk/qpid/cpp/src/qpid/client/AckPolicy.cpp   (with props)
Modified:
    incubator/qpid/trunk/qpid/cpp/src/Makefile.am
    incubator/qpid/trunk/qpid/cpp/src/qpid/client/AckPolicy.h

Modified: incubator/qpid/trunk/qpid/cpp/src/Makefile.am
URL: 
http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/Makefile.am?rev=661309&r1=661308&r2=661309&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/Makefile.am (original)
+++ incubator/qpid/trunk/qpid/cpp/src/Makefile.am Thu May 29 05:03:26 2008
@@ -316,7 +316,8 @@
 
 libqpidclient_la_SOURCES =                     \
   $(rgen_client_srcs)                          \
-  qpid/client/Bounds.cpp               \
+  qpid/client/AckPolicy.cpp                    \
+  qpid/client/Bounds.cpp                       \
   qpid/client/ConnectionImpl.cpp               \
   qpid/client/Connector.cpp                    \
   qpid/client/Connection.cpp                   \

Added: incubator/qpid/trunk/qpid/cpp/src/qpid/client/AckPolicy.cpp
URL: 
http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/client/AckPolicy.cpp?rev=661309&view=auto
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/client/AckPolicy.cpp (added)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/client/AckPolicy.cpp Thu May 29 
05:03:26 2008
@@ -0,0 +1,50 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+#include "AckPolicy.h"
+
+namespace qpid {
+namespace client {
+
+AckPolicy::AckPolicy(size_t n) : interval(n), count(n) {}
+
+void AckPolicy::ack(const Message& msg, AsyncSession session) 
+{
+    accepted.add(msg.getId());
+    if (interval && --count==0) {
+        session.markCompleted(msg.getId(), false, true);        
+        session.messageAccept(accepted);
+        accepted.clear();
+        count = interval;
+    } else {
+        session.markCompleted(msg.getId(), false, false);        
+    }
+}
+
+void AckPolicy::ackOutstanding(AsyncSession session) 
+{
+    if (!accepted.empty()) {
+        session.messageAccept(accepted);
+        accepted.clear();
+        session.sendCompletion();
+    }
+}
+
+}} // namespace qpid::client

Propchange: incubator/qpid/trunk/qpid/cpp/src/qpid/client/AckPolicy.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/qpid/trunk/qpid/cpp/src/qpid/client/AckPolicy.cpp
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: incubator/qpid/trunk/qpid/cpp/src/qpid/client/AckPolicy.h
URL: 
http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/client/AckPolicy.h?rev=661309&r1=661308&r2=661309&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/client/AckPolicy.h (original)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/client/AckPolicy.h Thu May 29 
05:03:26 2008
@@ -23,6 +23,7 @@
 
 #include "qpid/framing/SequenceSet.h"
 #include "qpid/client/AsyncSession.h"
+#include "qpid/client/Message.h"
 
 namespace qpid {
 namespace client {
@@ -40,32 +41,14 @@
 
   public:
     /**
+     * Sends accepts and marks completion of received transfers.
+     * 
      [EMAIL PROTECTED] n: acknowledge every n messages.
      *n==0 means no automatic acknowledgement.
      */
-    AckPolicy(size_t n=1) : interval(n), count(n) {}
-
-    void ack(const Message& msg, AsyncSession session) {
-        accepted.add(msg.getId());
-        if (!interval) return;
-        if (--count==0) {
-            session.markCompleted(msg.getId(), false, true);        
-            session.messageAccept(accepted);
-            accepted.clear();
-            count = interval;
-        } else {
-            session.markCompleted(msg.getId(), false, false);        
-        }
-    }
-
-    void ackOutstanding(AsyncSession session) {
-        if (!accepted.empty()) {
-            session.messageAccept(accepted);
-            accepted.clear();
-            session.sendCompletion();
-        }
-    }
-};
+    AckPolicy(size_t n=1);
+    void ack(const Message& msg, AsyncSession session);
+    void ackOutstanding(AsyncSession session);};
 
 }} // namespace qpid::client
 


Reply via email to