Repository: qpid-proton
Updated Branches:
  refs/heads/master 6f88f525e -> b17671eef


PROTON-1400: [C++ example] Use multiple threads in broker example if available


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

Branch: refs/heads/master
Commit: b17671eefa3a13579f858cd7a72df4231058a429
Parents: 2a60653
Author: Andrew Stitcher <[email protected]>
Authored: Fri May 26 17:01:00 2017 -0400
Committer: Andrew Stitcher <[email protected]>
Committed: Fri Jul 21 12:50:06 2017 -0400

----------------------------------------------------------------------
 examples/cpp/broker.cpp | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/b17671ee/examples/cpp/broker.cpp
----------------------------------------------------------------------
diff --git a/examples/cpp/broker.cpp b/examples/cpp/broker.cpp
index 2cb2b36..01dab36 100644
--- a/examples/cpp/broker.cpp
+++ b/examples/cpp/broker.cpp
@@ -44,11 +44,19 @@
 #include <map>
 #include <string>
 
+#if PN_CPP_SUPPORTS_THREADS
+#include <thread>
+#endif
+
 #include "fake_cpp11.hpp"
 
 // This is a simplified model for a message broker, that only allows for 
messages to go to a
 // single receiver.
 //
+// This broker is multithread safe and if compiled with C++11 with a 
multithreaded Proton
+// binding library will use as many threads as there are thread resources 
available (usually
+// cores)
+//
 // Queues are only created and never destroyed
 //
 // Broker Entities (that need to be individually serialised)
@@ -387,7 +395,12 @@ class broker {
     }
 
     void run() {
-        container_.run(/* std::thread::hardware_concurrency() */);
+#if PN_CPP_SUPPORTS_THREADS
+        std::cout << "starting " << std::thread::hardware_concurrency() << " 
listening threads\n";
+        container_.run(std::thread::hardware_concurrency());
+#else
+        container_.run();
+#endif
     }
 
   private:


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

Reply via email to