PROTON-1481: [C++ binding] Rename event_loop API to work_queue

Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/45d5612b
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/45d5612b
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/45d5612b

Branch: refs/heads/master
Commit: 45d5612bd674fa5055767ae66a261b9d81433edf
Parents: 2b2666b
Author: Andrew Stitcher <[email protected]>
Authored: Mon May 15 01:27:54 2017 -0400
Committer: Andrew Stitcher <[email protected]>
Committed: Fri Jul 21 12:50:06 2017 -0400

----------------------------------------------------------------------
 examples/cpp/broker.cpp                         | 40 ++++-----
 examples/cpp/scheduled_send.cpp                 | 12 +--
 examples/cpp/scheduled_send_03.cpp              | 10 +--
 proton-c/bindings/cpp/CMakeLists.txt            |  2 +-
 .../bindings/cpp/include/proton/container.hpp   |  2 +-
 .../bindings/cpp/include/proton/event_loop.hpp  | 94 --------------------
 proton-c/bindings/cpp/include/proton/fwd.hpp    |  2 +-
 .../cpp/include/proton/io/connection_driver.hpp |  2 +-
 .../bindings/cpp/include/proton/thread_safe.hpp | 12 +--
 .../bindings/cpp/include/proton/work_queue.hpp  | 94 ++++++++++++++++++++
 proton-c/bindings/cpp/src/connection.cpp        |  2 +-
 proton-c/bindings/cpp/src/event_loop.cpp        | 60 -------------
 proton-c/bindings/cpp/src/include/contexts.hpp  |  4 +-
 .../cpp/src/include/proactor_container_impl.hpp | 18 ++--
 .../src/include/proactor_event_loop_impl.hpp    | 43 ---------
 .../src/include/proactor_work_queue_impl.hpp    | 43 +++++++++
 .../bindings/cpp/src/io/connection_driver.cpp   |  2 +-
 .../cpp/src/proactor_container_impl.cpp         | 54 +++++------
 proton-c/bindings/cpp/src/work_queue.cpp        | 60 +++++++++++++
 19 files changed, 278 insertions(+), 278 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/45d5612b/examples/cpp/broker.cpp
----------------------------------------------------------------------
diff --git a/examples/cpp/broker.cpp b/examples/cpp/broker.cpp
index 2fbe077..8c2d2ff 100644
--- a/examples/cpp/broker.cpp
+++ b/examples/cpp/broker.cpp
@@ -136,25 +136,25 @@ struct work3 : public proton::void_function0 {
 template <class T>
 void defer(T* t, void (T::*f)()) {
     work0<T>* w = new work0<T>(*t, f);
-    t->inject(*w);
+    t->add(*w);
 }
 
 template <class T, class A>
 void defer(T* t, void (T::*f)(A), A a) {
     work1<T, A>* w = new work1<T, A>(*t, f, a);
-    t->inject(*w);
+    t->add(*w);
 }
 
 template <class T, class A, class B>
 void defer(T* t, void (T::*f)(A, B), A a, B b) {
     work2<T, A, B>* w = new work2<T, A, B>(*t, f, a, b);
-    t->inject(*w);
+    t->add(*w);
 }
 
 template <class T, class A, class B, class C>
 void defer(T* t, void (T::*f)(A, B, C), A a, B b, C c) {
     work3<T, A, B, C>* w = new work3<T, A, B, C>(*t, f, a, b, c);
-    t->inject(*w);
+    t->add(*w);
 }
 
 // Simple debug output
@@ -171,7 +171,7 @@ class Sender : public proton::messaging_handler {
 
     proton::sender sender_;
     senders& senders_;
-    proton::event_loop& event_loop_;
+    proton::work_queue& work_queue_;
     std::string queue_name_;
     Queue* queue_;
     int pending_credit_;
@@ -182,11 +182,11 @@ class Sender : public proton::messaging_handler {
 
 public:
     Sender(proton::sender s, senders& ss) :
-        sender_(s), senders_(ss), 
event_loop_(make_thread_safe(s).get()->event_loop()), queue_(0), 
pending_credit_(0)
+        sender_(s), senders_(ss), 
work_queue_(make_thread_safe(s).get()->work_queue()), queue_(0), 
pending_credit_(0)
     {}
 
-    void inject(proton::void_function0& f) {
-        event_loop_.inject(f);
+    void add(proton::void_function0& f) {
+        work_queue_.add(f);
     }
 
 
@@ -203,7 +203,7 @@ public:
 
 // Queue - round robin subscriptions
 class Queue {
-    proton::event_loop event_loop_;
+    proton::work_queue work_queue_;
     const std::string name_;
     std::deque<proton::message> messages_;
     typedef std::map<Sender*, int> subscriptions; // With credit
@@ -238,11 +238,11 @@ class Queue {
 
 public:
     Queue(proton::container& c, const std::string& n) :
-        event_loop_(c), name_(n), current_(subscriptions_.end())
+        work_queue_(c), name_(n), current_(subscriptions_.end())
     {}
 
-    void inject(proton::void_function0& f) {
-        event_loop_.inject(f);
+    void add(proton::void_function0& f) {
+        work_queue_.add(f);
     }
 
     void queueMsg(proton::message m) {
@@ -307,7 +307,7 @@ class Receiver : public proton::messaging_handler {
     friend class connection_handler;
 
     proton::receiver receiver_;
-    proton::event_loop& event_loop_;
+    proton::work_queue& work_queue_;
     Queue* queue_;
     std::deque<proton::message> messages_;
 
@@ -330,11 +330,11 @@ class Receiver : public proton::messaging_handler {
 
 public:
     Receiver(proton::receiver r) :
-        receiver_(r), event_loop_(make_thread_safe(r).get()->event_loop()), 
queue_(0)
+        receiver_(r), work_queue_(make_thread_safe(r).get()->work_queue()), 
queue_(0)
     {}
 
-    void inject(proton::void_function0& f) {
-        event_loop_.inject(f);
+    void add(proton::void_function0& f) {
+        work_queue_.add(f);
     }
 
     void boundQueue(Queue* q, std::string qn) {
@@ -351,18 +351,18 @@ public:
 
 class QueueManager {
     proton::container& container_;
-    proton::event_loop event_loop_;
+    proton::work_queue work_queue_;
     typedef std::map<std::string, Queue*> queues;
     queues queues_;
     int next_id_; // Use to generate unique queue IDs.
 
 public:
     QueueManager(proton::container& c) :
-        container_(c), event_loop_(c), next_id_(0)
+        container_(c), work_queue_(c), next_id_(0)
     {}
 
-    void inject(proton::void_function0& f) {
-        event_loop_.inject(f);
+    void add(proton::void_function0& f) {
+        work_queue_.add(f);
     }
 
     template <class T>

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/45d5612b/examples/cpp/scheduled_send.cpp
----------------------------------------------------------------------
diff --git a/examples/cpp/scheduled_send.cpp b/examples/cpp/scheduled_send.cpp
index de04c3b..bbef15b 100644
--- a/examples/cpp/scheduled_send.cpp
+++ b/examples/cpp/scheduled_send.cpp
@@ -23,12 +23,12 @@
 
 #include <proton/container.hpp>
 #include <proton/default_container.hpp>
-#include <proton/event_loop.hpp>
 #include <proton/message.hpp>
 #include <proton/messaging_handler.hpp>
 #include <proton/sender.hpp>
 #include <proton/thread_safe.hpp>
 #include <proton/tracker.hpp>
+#include <proton/work_queue.hpp>
 
 #include <iostream>
 
@@ -40,7 +40,7 @@ class scheduled_sender : public proton::messaging_handler {
     std::string url;
     proton::sender sender;
     proton::duration interval, timeout;
-    proton::event_loop* event_loop;
+    proton::work_queue* work_queue;
     bool ready, canceled;
 
   public:
@@ -57,11 +57,11 @@ class scheduled_sender : public proton::messaging_handler {
     // and must arrange lambdas for send and close to happen in the connection 
context.
     void on_container_start(proton::container &c) OVERRIDE {
         sender = c.open_sender(url);
-        event_loop = &proton::make_thread_safe(sender).get()->event_loop();
+        work_queue = &proton::make_thread_safe(sender).get()->work_queue();
         // Call this->cancel after timeout.
-        c.schedule(timeout, [this]() { this->event_loop->inject( [this]() { 
this->cancel(); }); });
+        c.schedule(timeout, [this]() { this->work_queue->add( [this]() { 
this->cancel(); }); });
          // Start regular ticks every interval.
-        c.schedule(interval, [this]() { this->event_loop->inject( [this]() { 
this->tick(); }); });
+        c.schedule(interval, [this]() { this->work_queue->add( [this]() { 
this->tick(); }); });
     }
 
     void cancel() {
@@ -72,7 +72,7 @@ class scheduled_sender : public proton::messaging_handler {
     void tick() {
         // Schedule the next tick unless we have been cancelled.
         if (!canceled)
-            sender.container().schedule(interval, [this]() { 
this->event_loop->inject( [this]() { this->tick(); }); });
+            sender.container().schedule(interval, [this]() { 
this->work_queue->add( [this]() { this->tick(); }); });
         if (sender.credit() > 0) // Only send if we have credit
             send();
         else

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/45d5612b/examples/cpp/scheduled_send_03.cpp
----------------------------------------------------------------------
diff --git a/examples/cpp/scheduled_send_03.cpp 
b/examples/cpp/scheduled_send_03.cpp
index d106d29..4b1b626 100644
--- a/examples/cpp/scheduled_send_03.cpp
+++ b/examples/cpp/scheduled_send_03.cpp
@@ -25,13 +25,13 @@
 #include <proton/connection.hpp>
 #include <proton/default_container.hpp>
 #include <proton/duration.hpp>
-#include <proton/event_loop.hpp>
 #include <proton/function.hpp>
 #include <proton/message.hpp>
 #include <proton/messaging_handler.hpp>
 #include <proton/sender.hpp>
 #include <proton/thread_safe.hpp>
 #include <proton/tracker.hpp>
+#include <proton/work_queue.hpp>
 
 #include <iostream>
 
@@ -43,7 +43,7 @@ class scheduled_sender : public proton::messaging_handler {
   private:
     std::string url;
     proton::duration interval, timeout;
-    proton::event_loop *event_loop;
+    proton::work_queue *work_queue;
     bool ready, canceled;
 
     struct cancel_fn : public proton::void_function0 {
@@ -65,13 +65,13 @@ class scheduled_sender : public proton::messaging_handler {
     struct defer_cancel_fn : public proton::void_function0 {
         scheduled_sender& parent;
         defer_cancel_fn(scheduled_sender& ss) : parent(ss) {}
-        void operator()() { parent.event_loop->inject(parent.do_cancel); }
+        void operator()() { parent.work_queue->add(parent.do_cancel); }
     };
 
     struct defer_tick_fn : public proton::void_function0 {
         scheduled_sender& parent;
         defer_tick_fn(scheduled_sender& ss) : parent(ss) {}
-        void operator()() { parent.event_loop->inject(parent.do_tick); }
+        void operator()() { parent.work_queue->add(parent.do_tick); }
     };
 
     tick_fn do_tick;
@@ -96,7 +96,7 @@ class scheduled_sender : public proton::messaging_handler {
     }
 
     void on_sender_open(proton::sender & s) OVERRIDE {
-        event_loop = &proton::make_thread_safe(s).get()->event_loop();
+        work_queue = &proton::make_thread_safe(s).get()->work_queue();
 
         do_cancel = cancel_fn(*this, s);
         do_tick = tick_fn(*this, s);

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/45d5612b/proton-c/bindings/cpp/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/CMakeLists.txt 
b/proton-c/bindings/cpp/CMakeLists.txt
index 625206f..21ff26c 100644
--- a/proton-c/bindings/cpp/CMakeLists.txt
+++ b/proton-c/bindings/cpp/CMakeLists.txt
@@ -44,7 +44,6 @@ set(qpid-proton-cpp-source
   src/endpoint.cpp
   src/error.cpp
   src/error_condition.cpp
-  src/event_loop.cpp
   src/handler.cpp
   src/io/connection_driver.cpp
   src/io/link_namer.cpp
@@ -77,6 +76,7 @@ set(qpid-proton-cpp-source
   src/url.cpp
   src/uuid.cpp
   src/value.cpp
+  src/work_queue.cpp
   )
 
 set_source_files_properties (

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/45d5612b/proton-c/bindings/cpp/include/proton/container.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/container.hpp 
b/proton-c/bindings/cpp/include/proton/container.hpp
index 0262e0f..383aa3c 100644
--- a/proton-c/bindings/cpp/include/proton/container.hpp
+++ b/proton-c/bindings/cpp/include/proton/container.hpp
@@ -224,7 +224,7 @@ class PN_CPP_CLASS_EXTERN container {
   friend class session_options;
   friend class receiver_options;
   friend class sender_options;
-  friend class event_loop;
+  friend class work_queue;
 };
 
 } // proton

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/45d5612b/proton-c/bindings/cpp/include/proton/event_loop.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/event_loop.hpp 
b/proton-c/bindings/cpp/include/proton/event_loop.hpp
deleted file mode 100644
index 6d1646e..0000000
--- a/proton-c/bindings/cpp/include/proton/event_loop.hpp
+++ /dev/null
@@ -1,94 +0,0 @@
-#ifndef PROTON_EVENT_LOOP_HPP
-#define PROTON_EVENT_LOOP_HPP
-
-/*
- *
- * 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 "./fwd.hpp"
-#include "./internal/config.hpp"
-#include "./internal/export.hpp"
-#include "./internal/pn_unique_ptr.hpp"
-
-#include <functional>
-
-struct pn_connection_t;
-struct pn_session_t;
-struct pn_link_t;
-
-namespace proton {
-
-/// **Experimental** - A serial execution context.
-///
-/// Event handler functions associated with a single proton::connection are 
called in sequence.
-/// The connection's @ref event_loop allows you to "inject" extra work from 
any thread,
-/// and have it executed in the same sequence.
-///
-class PN_CPP_CLASS_EXTERN event_loop {
-    /// @cond internal
-    class impl;
-    event_loop& operator=(impl* i);
-    /// @endcond
-
-  public:
-    /// Create event_loop
-    PN_CPP_EXTERN event_loop();
-    PN_CPP_EXTERN event_loop(container&);
-
-    PN_CPP_EXTERN ~event_loop();
-
-#if PN_CPP_HAS_EXPLICIT_CONVERSIONS
-    /// When using C++11 (or later) you can use event_loop in a bool context
-    /// to indicate if there is an event loop set.
-    PN_CPP_EXTERN explicit operator bool() const { return bool(impl_); }
-#endif
-
-    /// No event loop set.
-    PN_CPP_EXTERN bool operator !() const { return !impl_; }
-
-    /// Arrange to have f() called in the event_loop's sequence: possibly
-    /// deferred, possibly in another thread.
-    ///
-    /// @return true if f() has or will be called, false if the event_loop is 
ended
-    /// and f() cannot be injected.
-    PN_CPP_EXTERN bool inject(void_function0& f);
-
-#if PN_CPP_HAS_STD_FUNCTION
-    /// @copydoc inject(void_function0&)
-    PN_CPP_EXTERN bool inject(std::function<void()> f);
-#endif
-
-  private:
-    PN_CPP_EXTERN static event_loop& get(pn_connection_t*);
-    PN_CPP_EXTERN static event_loop& get(pn_session_t*);
-    PN_CPP_EXTERN static event_loop& get(pn_link_t*);
-
-    internal::pn_unique_ptr<impl> impl_;
-
-    /// @cond INTERNAL
-  friend class container;
-  friend class io::connection_driver;
-  template <class T> friend class thread_safe;
-    /// @endcond
-};
-
-} // proton
-
-#endif // PROTON_EVENT_LOOP_HPP

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/45d5612b/proton-c/bindings/cpp/include/proton/fwd.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/fwd.hpp 
b/proton-c/bindings/cpp/include/proton/fwd.hpp
index 54d7646..6ad216e 100644
--- a/proton-c/bindings/cpp/include/proton/fwd.hpp
+++ b/proton-c/bindings/cpp/include/proton/fwd.hpp
@@ -31,7 +31,7 @@ class container;
 class delivery;
 class error_condition;
 class event;
-class event_loop;
+class work_queue;
 class message;
 class message_id;
 class messaging_handler;

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/45d5612b/proton-c/bindings/cpp/include/proton/io/connection_driver.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/io/connection_driver.hpp 
b/proton-c/bindings/cpp/include/proton/io/connection_driver.hpp
index 8d0be85..5df210d 100644
--- a/proton-c/bindings/cpp/include/proton/io/connection_driver.hpp
+++ b/proton-c/bindings/cpp/include/proton/io/connection_driver.hpp
@@ -40,7 +40,7 @@
 
 namespace proton {
 
-class event_loop;
+class work_queue;
 class proton_handler;
 
 namespace io {

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/45d5612b/proton-c/bindings/cpp/include/proton/thread_safe.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/thread_safe.hpp 
b/proton-c/bindings/cpp/include/proton/thread_safe.hpp
index 608a1ca..e5f5303 100644
--- a/proton-c/bindings/cpp/include/proton/thread_safe.hpp
+++ b/proton-c/bindings/cpp/include/proton/thread_safe.hpp
@@ -25,10 +25,10 @@
 #include "./fwd.hpp"
 #include "./internal/config.hpp"
 #include "./connection.hpp"
-#include "./event_loop.hpp"
 #include "./function.hpp"
 #include "./internal/object.hpp"
 #include "./internal/type_traits.hpp"
+#include "./work_queue.hpp"
 
 #include <functional>
 
@@ -76,11 +76,11 @@ class thread_safe : private internal::pn_ptr_base, private 
internal::endpoint_tr
 
     ~thread_safe() {
         if (ptr()) {
-            if (!!event_loop()) {
+            if (!!work_queue()) {
 #if PN_CPP_HAS_STD_BIND
-                event_loop().inject(std::bind(&decref, ptr()));
+                work_queue().add(std::bind(&decref, ptr()));
 #else
-                event_loop().inject(*new inject_decref(ptr()));
+                work_queue().add(*new inject_decref(ptr()));
 #endif
             } else {
                 decref(ptr());
@@ -88,8 +88,8 @@ class thread_safe : private internal::pn_ptr_base, private 
internal::endpoint_tr
         }
     }
 
-    /// Get the event loop for this object.
-    class event_loop& event_loop() { return event_loop::get(ptr()); }
+    /// Get the work queue for this object.
+    class work_queue& work_queue() { return work_queue::get(ptr()); }
 
     /// Get the thread-unsafe proton object wrapped by this thread_safe<T>
     T unsafe() { return T(ptr()); }

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/45d5612b/proton-c/bindings/cpp/include/proton/work_queue.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/work_queue.hpp 
b/proton-c/bindings/cpp/include/proton/work_queue.hpp
new file mode 100644
index 0000000..7acd507
--- /dev/null
+++ b/proton-c/bindings/cpp/include/proton/work_queue.hpp
@@ -0,0 +1,94 @@
+#ifndef PROTON_WORK_QUEUE_HPP
+#define PROTON_WORK_QUEUE_HPP
+
+/*
+ *
+ * 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 "./fwd.hpp"
+#include "./internal/config.hpp"
+#include "./internal/export.hpp"
+#include "./internal/pn_unique_ptr.hpp"
+
+#include <functional>
+
+struct pn_connection_t;
+struct pn_session_t;
+struct pn_link_t;
+
+namespace proton {
+
+/// **Experimental** - A serial execution context.
+///
+/// Event handler functions associated with a single proton::connection are 
called in sequence.
+/// The connection's @ref event_loop allows you to "inject" extra work from 
any thread,
+/// and have it executed in the same sequence.
+///
+class PN_CPP_CLASS_EXTERN work_queue {
+    /// @cond internal
+    class impl;
+    work_queue& operator=(impl* i);
+    /// @endcond
+
+  public:
+    /// Create event_loop
+    PN_CPP_EXTERN work_queue();
+    PN_CPP_EXTERN work_queue(container&);
+
+    PN_CPP_EXTERN ~work_queue();
+
+#if PN_CPP_HAS_EXPLICIT_CONVERSIONS
+    /// When using C++11 (or later) you can use event_loop in a bool context
+    /// to indicate if there is an event loop set.
+    PN_CPP_EXTERN explicit operator bool() const { return bool(impl_); }
+#endif
+
+    /// No event loop set.
+    PN_CPP_EXTERN bool operator !() const { return !impl_; }
+
+    /// Arrange to have f() called in the event_loop's sequence: possibly
+    /// deferred, possibly in another thread.
+    ///
+    /// @return true if f() has or will be called, false if the event_loop is 
ended
+    /// and f() cannot be injected.
+    PN_CPP_EXTERN bool add(void_function0& f);
+
+#if PN_CPP_HAS_STD_FUNCTION
+    /// @copydoc inject(void_function0&)
+    PN_CPP_EXTERN bool add(std::function<void()> f);
+#endif
+
+  private:
+    PN_CPP_EXTERN static work_queue& get(pn_connection_t*);
+    PN_CPP_EXTERN static work_queue& get(pn_session_t*);
+    PN_CPP_EXTERN static work_queue& get(pn_link_t*);
+
+    internal::pn_unique_ptr<impl> impl_;
+
+    /// @cond INTERNAL
+  friend class container;
+  friend class io::connection_driver;
+  template <class T> friend class thread_safe;
+    /// @endcond
+};
+
+} // proton
+
+#endif // PROTON_WORK_QUEUE_HPP

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/45d5612b/proton-c/bindings/cpp/src/connection.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/connection.cpp 
b/proton-c/bindings/cpp/src/connection.cpp
index 11d5624..5432a42 100644
--- a/proton-c/bindings/cpp/src/connection.cpp
+++ b/proton-c/bindings/cpp/src/connection.cpp
@@ -25,12 +25,12 @@
 #include "proton/connection_options.hpp"
 #include "proton/container.hpp"
 #include "proton/error.hpp"
-#include "proton/event_loop.hpp"
 #include "proton/receiver_options.hpp"
 #include "proton/sender_options.hpp"
 #include "proton/session.hpp"
 #include "proton/session_options.hpp"
 #include "proton/transport.hpp"
+#include "proton/work_queue.hpp"
 
 #include "contexts.hpp"
 #include "msg.hpp"

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/45d5612b/proton-c/bindings/cpp/src/event_loop.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/event_loop.cpp 
b/proton-c/bindings/cpp/src/event_loop.cpp
deleted file mode 100644
index 5320011..0000000
--- a/proton-c/bindings/cpp/src/event_loop.cpp
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * 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 "proton/event_loop.hpp"
-
-#include "contexts.hpp"
-#include "proactor_container_impl.hpp"
-#include "proactor_event_loop_impl.hpp"
-
-#include <proton/session.h>
-#include <proton/link.h>
-
-namespace proton {
-
-event_loop::event_loop() {}
-event_loop::event_loop(container& c) { *this = 
container::impl::make_event_loop(c); }
-
-event_loop::~event_loop() {}
-
-event_loop& event_loop::operator=(impl* i) { impl_.reset(i); return *this; }
-
-bool event_loop::inject(void_function0& f) {
-    return impl_->inject(f);
-}
-
-#if PN_CPP_HAS_STD_FUNCTION
-bool event_loop::inject(std::function<void()> f) {
-    return impl_->inject(f);
-}
-#endif
-
-event_loop& event_loop::get(pn_connection_t* c) {
-    return connection_context::get(c).event_loop_;
-}
-
-event_loop& event_loop::get(pn_session_t* s) {
-    return get(pn_session_connection(s));
-}
-
-event_loop& event_loop::get(pn_link_t* l) {
-    return get(pn_link_session(l));
-}
-
-}

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/45d5612b/proton-c/bindings/cpp/src/include/contexts.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/include/contexts.hpp 
b/proton-c/bindings/cpp/src/include/contexts.hpp
index ab0661a..0c829db 100644
--- a/proton-c/bindings/cpp/src/include/contexts.hpp
+++ b/proton-c/bindings/cpp/src/include/contexts.hpp
@@ -22,7 +22,7 @@
  *
  */
 
-#include "proton/event_loop.hpp"
+#include "proton/work_queue.hpp"
 #include "proton/message.hpp"
 #include "proton/internal/pn_unique_ptr.hpp"
 
@@ -92,7 +92,7 @@ class connection_context : public context {
     messaging_handler* handler;
     internal::pn_unique_ptr<reconnect_timer> reconnect;
     listener_context* listener_context_;
-    event_loop event_loop_;
+    work_queue work_queue_;
 };
 
 class listener_context : public context {

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/45d5612b/proton-c/bindings/cpp/src/include/proactor_container_impl.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/include/proactor_container_impl.hpp 
b/proton-c/bindings/cpp/src/include/proactor_container_impl.hpp
index 4b84a6e..9b4be11 100644
--- a/proton-c/bindings/cpp/src/include/proactor_container_impl.hpp
+++ b/proton-c/bindings/cpp/src/include/proactor_container_impl.hpp
@@ -28,12 +28,12 @@
 #include "proton/connection_options.hpp"
 #include "proton/duration.hpp"
 #include "proton/error_condition.hpp"
-#include "proton/event_loop.hpp"
 #include "proton/messaging_handler.hpp"
 #include "proton/receiver.hpp"
 #include "proton/receiver_options.hpp"
 #include "proton/sender.hpp"
 #include "proton/sender_options.hpp"
+#include "proton/work_queue.hpp"
 
 #include "proton_bits.hpp"
 
@@ -79,12 +79,12 @@ class container::impl {
 #endif
     template <class T> static void set_handler(T s, messaging_handler* h);
     template <class T> static messaging_handler* get_handler(T s);
-    static event_loop::impl* make_event_loop(container&);
+    static work_queue::impl* make_work_queue(container&);
 
   private:
-    class common_event_loop;
-    class connection_event_loop;
-    class container_event_loop;
+    class common_work_queue;
+    class connection_work_queue;
+    class container_work_queue;
     pn_listener_t* listen_common_lh(const std::string&);
     connection connect_common(const std::string&, const connection_options&);
 
@@ -95,10 +95,10 @@ class container::impl {
 
     container& container_;
 
-    typedef std::set<container_event_loop*> event_loops;
-    event_loops event_loops_;
-    container_event_loop* add_event_loop();
-    void remove_event_loop(container_event_loop*);
+    typedef std::set<container_work_queue*> work_queues;
+    work_queues work_queues_;
+    container_work_queue* add_work_queue();
+    void remove_work_queue(container_work_queue*);
     struct scheduled {
         timestamp time; // duration from epoch for task
 #if PN_CPP_HAS_STD_FUNCTION

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/45d5612b/proton-c/bindings/cpp/src/include/proactor_event_loop_impl.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/include/proactor_event_loop_impl.hpp 
b/proton-c/bindings/cpp/src/include/proactor_event_loop_impl.hpp
deleted file mode 100644
index 82ec129..0000000
--- a/proton-c/bindings/cpp/src/include/proactor_event_loop_impl.hpp
+++ /dev/null
@@ -1,43 +0,0 @@
-#ifndef PROTON_CPP_EVENT_LOOP_IMPL_HPP
-#define PROTON_CPP_EVENT_LOOP_IMPL_HPP
-
-/*
- *
- * 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 "proton/fwd.hpp"
-#include "proton/internal/config.hpp"
-
-namespace proton {
-
-class event_loop::impl {
-  public:
-    virtual ~impl() {};
-    virtual bool inject(void_function0& f) = 0;
-#if PN_CPP_HAS_STD_FUNCTION
-    virtual bool inject(std::function<void()> f) = 0;
-#endif
-    virtual void run_all_jobs() = 0;
-    virtual void finished() = 0;
-};
-
-}
-
-#endif // PROTON_CPP_EVENT_LOOP_IMPL_HPP

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/45d5612b/proton-c/bindings/cpp/src/include/proactor_work_queue_impl.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/include/proactor_work_queue_impl.hpp 
b/proton-c/bindings/cpp/src/include/proactor_work_queue_impl.hpp
new file mode 100644
index 0000000..57fc4c0
--- /dev/null
+++ b/proton-c/bindings/cpp/src/include/proactor_work_queue_impl.hpp
@@ -0,0 +1,43 @@
+#ifndef PROTON_CPP_EVENT_LOOP_IMPL_HPP
+#define PROTON_CPP_EVENT_LOOP_IMPL_HPP
+
+/*
+ *
+ * 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 "proton/fwd.hpp"
+#include "proton/internal/config.hpp"
+
+namespace proton {
+
+class work_queue::impl {
+  public:
+    virtual ~impl() {};
+    virtual bool inject(void_function0& f) = 0;
+#if PN_CPP_HAS_STD_FUNCTION
+    virtual bool inject(std::function<void()> f) = 0;
+#endif
+    virtual void run_all_jobs() = 0;
+    virtual void finished() = 0;
+};
+
+}
+
+#endif // PROTON_CPP_EVENT_LOOP_IMPL_HPP

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/45d5612b/proton-c/bindings/cpp/src/io/connection_driver.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/io/connection_driver.cpp 
b/proton-c/bindings/cpp/src/io/connection_driver.cpp
index 58af052..d907e5c 100644
--- a/proton-c/bindings/cpp/src/io/connection_driver.cpp
+++ b/proton-c/bindings/cpp/src/io/connection_driver.cpp
@@ -20,10 +20,10 @@
 #include "proton/io/connection_driver.hpp"
 
 #include "proton/container.hpp"
-#include "proton/event_loop.hpp"
 #include "proton/error.hpp"
 #include "proton/messaging_handler.hpp"
 #include "proton/uuid.hpp"
+#include "proton/work_queue.hpp"
 
 #include "contexts.hpp"
 #include "messaging_adapter.hpp"

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/45d5612b/proton-c/bindings/cpp/src/proactor_container_impl.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/proactor_container_impl.cpp 
b/proton-c/bindings/cpp/src/proactor_container_impl.cpp
index 4d526f2..78ccabf 100644
--- a/proton-c/bindings/cpp/src/proactor_container_impl.cpp
+++ b/proton-c/bindings/cpp/src/proactor_container_impl.cpp
@@ -18,7 +18,7 @@
  */
 
 #include "proactor_container_impl.hpp"
-#include "proactor_event_loop_impl.hpp"
+#include "proactor_work_queue_impl.hpp"
 
 #include "proton/error_condition.hpp"
 #include "proton/function.hpp"
@@ -43,9 +43,9 @@
 
 namespace proton {
 
-class container::impl::common_event_loop : public event_loop::impl {
+class container::impl::common_work_queue : public work_queue::impl {
   public:
-    common_event_loop(): finished_(false) {}
+    common_work_queue(): finished_(false) {}
 
 #if PN_CPP_HAS_STD_FUNCTION
     typedef std::vector<std::function<void()> > jobs;
@@ -61,7 +61,7 @@ class container::impl::common_event_loop : public 
event_loop::impl {
 };
 
 #if PN_CPP_HAS_STD_FUNCTION
-void container::impl::common_event_loop::run_all_jobs() {
+void container::impl::common_work_queue::run_all_jobs() {
     decltype(jobs_) j;
     {
         std::swap(j, jobs_);
@@ -72,7 +72,7 @@ void container::impl::common_event_loop::run_all_jobs() {
     } catch (...) {};
 }
 #else
-void container::impl::common_event_loop::run_all_jobs() {
+void container::impl::common_work_queue::run_all_jobs() {
     // Run queued work, but ignore any exceptions
     for (jobs::iterator f = jobs_.begin(); f != jobs_.end(); ++f) try {
         (**f)();
@@ -82,9 +82,9 @@ void container::impl::common_event_loop::run_all_jobs() {
 }
 #endif
 
-class container::impl::connection_event_loop : public common_event_loop {
+class container::impl::connection_work_queue : public common_work_queue {
   public:
-    connection_event_loop(pn_connection_t* c): connection_(c) {}
+    connection_work_queue(pn_connection_t* c): connection_(c) {}
 
     bool inject(void_function0& f);
 #if PN_CPP_HAS_STD_FUNCTION
@@ -95,7 +95,7 @@ class container::impl::connection_event_loop : public 
common_event_loop {
 };
 
 #if PN_CPP_HAS_STD_FUNCTION
-bool container::impl::connection_event_loop::inject(std::function<void()> f) {
+bool container::impl::connection_work_queue::inject(std::function<void()> f) {
     // Note this is an unbounded work queue.
     // A resource-safe implementation should be bounded.
     if (finished_) return false;
@@ -104,11 +104,11 @@ bool 
container::impl::connection_event_loop::inject(std::function<void()> f) {
     return true;
 }
 
-bool container::impl::connection_event_loop::inject(proton::void_function0& f) 
{
+bool container::impl::connection_work_queue::inject(proton::void_function0& f) 
{
     return inject([&f]() { f(); });
 }
 #else
-bool container::impl::connection_event_loop::inject(proton::void_function0& f) 
{
+bool container::impl::connection_work_queue::inject(proton::void_function0& f) 
{
     // Note this is an unbounded work queue.
     // A resource-safe implementation should be bounded.
     if (finished_) return false;
@@ -118,10 +118,10 @@ bool 
container::impl::connection_event_loop::inject(proton::void_function0& f) {
 }
 #endif
 
-class container::impl::container_event_loop : public common_event_loop {
+class container::impl::container_work_queue : public common_work_queue {
   public:
-    container_event_loop(container::impl& c): container_(c) {}
-    ~container_event_loop() { container_.remove_event_loop(this); }
+    container_work_queue(container::impl& c): container_(c) {}
+    ~container_work_queue() { container_.remove_work_queue(this); }
 
     bool inject(void_function0& f);
 #if PN_CPP_HAS_STD_FUNCTION
@@ -132,7 +132,7 @@ class container::impl::container_event_loop : public 
common_event_loop {
 };
 
 #if PN_CPP_HAS_STD_FUNCTION
-bool container::impl::container_event_loop::inject(std::function<void()> f) {
+bool container::impl::container_work_queue::inject(std::function<void()> f) {
     // Note this is an unbounded work queue.
     // A resource-safe implementation should be bounded.
     if (finished_) return false;
@@ -141,11 +141,11 @@ bool 
container::impl::container_event_loop::inject(std::function<void()> f) {
     return true;
 }
 
-bool container::impl::container_event_loop::inject(proton::void_function0& f) {
+bool container::impl::container_work_queue::inject(proton::void_function0& f) {
     return inject([&f]() { f(); });
 }
 #else
-bool container::impl::container_event_loop::inject(proton::void_function0& f) {
+bool container::impl::container_work_queue::inject(proton::void_function0& f) {
     // Note this is an unbounded work queue.
     // A resource-safe implementation should be bounded.
     if (finished_) return false;
@@ -155,8 +155,8 @@ bool 
container::impl::container_event_loop::inject(proton::void_function0& f) {
 }
 #endif
 
-class event_loop::impl* container::impl::make_event_loop(container& c) {
-    return c.impl_->add_event_loop();
+class work_queue::impl* container::impl::make_work_queue(container& c) {
+    return c.impl_->add_work_queue();
 }
 
 container::impl::impl(container& c, const std::string& id, messaging_handler* 
mh)
@@ -172,14 +172,14 @@ container::impl::~impl() {
     pn_proactor_free(proactor_);
 }
 
-container::impl::container_event_loop* container::impl::add_event_loop() {
-    container_event_loop* c = new container_event_loop(*this);
-    event_loops_.insert(c);
+container::impl::container_work_queue* container::impl::add_work_queue() {
+    container_work_queue* c = new container_work_queue(*this);
+    work_queues_.insert(c);
     return c;
 }
 
-void container::impl::remove_event_loop(container::impl::container_event_loop* 
l) {
-    event_loops_.erase(l);
+void container::impl::remove_work_queue(container::impl::container_work_queue* 
l) {
+    work_queues_.erase(l);
 }
 
 proton::connection container::impl::connect_common(
@@ -198,7 +198,7 @@ proton::connection container::impl::connect_common(
     connection_context& cc(connection_context::get(pnc));
     cc.container = &container_;
     cc.handler = mh;
-    cc.event_loop_ = new container::impl::connection_event_loop(pnc);
+    cc.work_queue_ = new container::impl::connection_work_queue(pnc);
 
     pn_connection_set_container(pnc, id_.c_str());
     pn_connection_set_hostname(pnc, url.host().c_str());
@@ -344,7 +344,7 @@ bool container::impl::handle(pn_event_t* event) {
     // If we have any pending connection work, do it now
     pn_connection_t* c = pn_event_connection(event);
     if (c) {
-        event_loop::impl* loop = 
connection_context::get(c).event_loop_.impl_.get();
+        work_queue::impl* loop = 
connection_context::get(c).work_queue_.impl_.get();
         loop->run_all_jobs();
     }
 
@@ -367,7 +367,7 @@ bool container::impl::handle(pn_event_t* event) {
         // Run every container event loop job
         // This is not at all efficient and single threads all these jobs, but 
it does correctly
         // serialise them
-        for (event_loops::iterator loop = event_loops_.begin(); 
loop!=event_loops_.end(); ++loop) {
+        for (work_queues::iterator loop = work_queues_.begin(); 
loop!=work_queues_.end(); ++loop) {
             (*loop)->run_all_jobs();
         }
         return false;
@@ -392,7 +392,7 @@ bool container::impl::handle(pn_event_t* event) {
         cc.container = &container_;
         cc.listener_context_ = &lc;
         cc.handler = opts.handler();
-        cc.event_loop_ = new container::impl::connection_event_loop(c);
+        cc.work_queue_ = new container::impl::connection_work_queue(c);
         pn_listener_accept(l, c);
         return false;
     }

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/45d5612b/proton-c/bindings/cpp/src/work_queue.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/work_queue.cpp 
b/proton-c/bindings/cpp/src/work_queue.cpp
new file mode 100644
index 0000000..961e5f0
--- /dev/null
+++ b/proton-c/bindings/cpp/src/work_queue.cpp
@@ -0,0 +1,60 @@
+/*
+ * 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 "proton/work_queue.hpp"
+
+#include "contexts.hpp"
+#include "proactor_container_impl.hpp"
+#include "proactor_work_queue_impl.hpp"
+
+#include <proton/session.h>
+#include <proton/link.h>
+
+namespace proton {
+
+work_queue::work_queue() {}
+work_queue::work_queue(container& c) { *this = 
container::impl::make_work_queue(c); }
+
+work_queue::~work_queue() {}
+
+work_queue& work_queue::operator=(impl* i) { impl_.reset(i); return *this; }
+
+bool work_queue::add(void_function0& f) {
+    return impl_->inject(f);
+}
+
+#if PN_CPP_HAS_STD_FUNCTION
+bool work_queue::add(std::function<void()> f) {
+    return impl_->inject(f);
+}
+#endif
+
+work_queue& work_queue::get(pn_connection_t* c) {
+    return connection_context::get(c).work_queue_;
+}
+
+work_queue& work_queue::get(pn_session_t* s) {
+    return get(pn_session_connection(s));
+}
+
+work_queue& work_queue::get(pn_link_t* l) {
+    return get(pn_link_session(l));
+}
+
+}


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to