qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From acon...@apache.org
Subject qpid-proton git commit: NO-JIRA: c++: inline messaging_handler, remove allocations.
Date Mon, 15 Aug 2016 15:05:28 GMT
Repository: qpid-proton
Updated Branches:
  refs/heads/master dd64f5411 -> 8ca7e2a53


NO-JIRA: c++: inline messaging_handler, remove allocations.

Remove un-necessary heap alloc of messaging_handler in connection_engine:

Ensure messaging_adapter ctor and dtor are inline.
Stack alloc the messaging_adapter in every dispatch()
Inline ctor/dtor are free in an optimized build, and we avoid the heap alloc.


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

Branch: refs/heads/master
Commit: 8ca7e2a538d0779715c1e410407b69d7a83de09f
Parents: dd64f54
Author: Alan Conway <aconway@redhat.com>
Authored: Mon Aug 15 15:42:58 2016 +0100
Committer: Alan Conway <aconway@redhat.com>
Committed: Mon Aug 15 16:03:40 2016 +0100

----------------------------------------------------------------------
 proton-c/bindings/cpp/include/proton/io/connection_engine.hpp | 2 +-
 proton-c/bindings/cpp/src/io/connection_engine.cpp            | 7 +++++--
 proton-c/bindings/cpp/src/messaging_adapter.cpp               | 4 ----
 proton-c/bindings/cpp/src/messaging_adapter.hpp               | 3 +--
 4 files changed, 7 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/8ca7e2a5/proton-c/bindings/cpp/include/proton/io/connection_engine.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/io/connection_engine.hpp b/proton-c/bindings/cpp/include/proton/io/connection_engine.hpp
index a492191..70e6754 100644
--- a/proton-c/bindings/cpp/include/proton/io/connection_engine.hpp
+++ b/proton-c/bindings/cpp/include/proton/io/connection_engine.hpp
@@ -203,7 +203,7 @@ PN_CPP_CLASS_EXTERN connection_engine {
     connection_engine(const connection_engine&);
     connection_engine& operator=(const connection_engine&);
 
-    internal::pn_unique_ptr<proton_handler> handler_;
+    messaging_handler* handler_;
     proton::container* container_;
     pn_connection_engine_t c_engine_;
 };

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/8ca7e2a5/proton-c/bindings/cpp/src/io/connection_engine.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/io/connection_engine.cpp b/proton-c/bindings/cpp/src/io/connection_engine.cpp
index e520547..4ca4ce3 100644
--- a/proton-c/bindings/cpp/src/io/connection_engine.cpp
+++ b/proton-c/bindings/cpp/src/io/connection_engine.cpp
@@ -63,7 +63,7 @@ void connection_engine::configure(const connection_options& opts) {
     proton::connection c = connection();
     opts.apply_unbound(c);
     opts.apply_bound(c);
-    handler_.reset(new messaging_adapter(*opts.handler()));
+    handler_ =  opts.handler();
     connection_context::get(connection()).collector = c_engine_.collector;
 }
 
@@ -97,7 +97,10 @@ bool connection_engine::dispatch() {
     while ((c_event = pn_connection_engine_dispatch(&c_engine_)) != NULL) {
         proton_event cpp_event(c_event, container_);
         try {
-            if (!!handler_) cpp_event.dispatch(*handler_);
+            if (handler_ != 0) {
+                messaging_adapter adapter(*handler_);
+                cpp_event.dispatch(adapter);
+            }
         } catch (const std::exception& e) {
             disconnected(error_condition("exception", e.what()));
         }

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/8ca7e2a5/proton-c/bindings/cpp/src/messaging_adapter.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/messaging_adapter.cpp b/proton-c/bindings/cpp/src/messaging_adapter.cpp
index 37fc4e0..928c3be 100644
--- a/proton-c/bindings/cpp/src/messaging_adapter.cpp
+++ b/proton-c/bindings/cpp/src/messaging_adapter.cpp
@@ -54,10 +54,6 @@ void credit_topup(pn_link_t *link) {
 }
 }
 
-messaging_adapter::messaging_adapter(messaging_handler &delegate) : delegate_(delegate)
{}
-
-messaging_adapter::~messaging_adapter(){}
-
 void messaging_adapter::on_reactor_init(proton_event &pe) {
     delegate_.on_container_start(pe.container());
 }

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/8ca7e2a5/proton-c/bindings/cpp/src/messaging_adapter.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/messaging_adapter.hpp b/proton-c/bindings/cpp/src/messaging_adapter.hpp
index 846b466..5371eec 100644
--- a/proton-c/bindings/cpp/src/messaging_adapter.hpp
+++ b/proton-c/bindings/cpp/src/messaging_adapter.hpp
@@ -37,8 +37,7 @@ namespace proton {
 class messaging_adapter : public proton_handler
 {
   public:
-    messaging_adapter(messaging_handler &delegate);
-    virtual ~messaging_adapter();
+    messaging_adapter(messaging_handler &delegate) : delegate_(delegate) {}
 
     void on_reactor_init(proton_event &e);
     void on_reactor_final(proton_event & e);


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


Mime
View raw message