qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From astitc...@apache.org
Subject [1/3] qpid-proton git commit: PROTON-1302: Rewrite proton::timestamp::now in terms of std::chrono and make it C++11 only - Portability and allows independence of proton-c platform code
Date Thu, 15 Sep 2016 14:55:35 GMT
Repository: qpid-proton
Updated Branches:
  refs/heads/master 12a6e4d33 -> 077eea5a8


PROTON-1302: Rewrite proton::timestamp::now in terms of std::chrono and make it C++11 only
- Portability and allows independence of proton-c platform code


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

Branch: refs/heads/master
Commit: bf615adf6da3c0654211fc637caccd073dc6a48a
Parents: 477d53b
Author: Andrew Stitcher <astitcher@apache.org>
Authored: Tue Sep 13 13:48:54 2016 -0400
Committer: Andrew Stitcher <astitcher@apache.org>
Committed: Thu Sep 15 09:54:50 2016 -0400

----------------------------------------------------------------------
 .../bindings/cpp/include/proton/internal/config.hpp     |  4 ++++
 proton-c/bindings/cpp/src/timestamp.cpp                 | 12 +++++++++++-
 2 files changed, 15 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/bf615adf/proton-c/bindings/cpp/include/proton/internal/config.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/internal/config.hpp b/proton-c/bindings/cpp/include/proton/internal/config.hpp
index cd5370e..612e1e3 100644
--- a/proton-c/bindings/cpp/include/proton/internal/config.hpp
+++ b/proton-c/bindings/cpp/include/proton/internal/config.hpp
@@ -87,6 +87,10 @@
 #define PN_CPP_HAS_STD_FUNCTION PN_CPP_HAS_CPP11
 #endif
 
+#ifndef PN_CPP_HAS_CHRONO
+#define PN_CPP_HAS_CHRONO PN_CPP_HAS_CPP11
+#endif
+
 #endif // PROTON_INTERNAL_CONFIG_HPP
 
 /// @endcond

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/bf615adf/proton-c/bindings/cpp/src/timestamp.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/timestamp.cpp b/proton-c/bindings/cpp/src/timestamp.cpp
index 2a3e8a9..b763096 100644
--- a/proton-c/bindings/cpp/src/timestamp.cpp
+++ b/proton-c/bindings/cpp/src/timestamp.cpp
@@ -18,14 +18,24 @@
  */
 
 #include "proton/timestamp.hpp"
+
+#include "proton/internal/config.hpp"
 #include <proton/types.h>
+
 #include <iostream>
 
+#if PN_CPP_HAS_CHRONO
+#include <chrono>
+#endif
+
 namespace proton {
 
+#if PN_CPP_HAS_CHRONO
 timestamp timestamp::now() {
-    return timestamp(pn_timestamp_now());
+    using namespace std::chrono;
+    return timestamp( duration_cast<std::chrono::milliseconds>(system_clock::now().time_since_epoch()).count()
);
 }
+#endif
 
 std::ostream& operator<<(std::ostream& o, timestamp ts) { return o <<
ts.milliseconds(); }
 


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


Mime
View raw message