You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@celix.apache.org by pe...@apache.org on 2023/12/13 09:37:06 UTC

(celix) branch hotfix/system-clock-replace created (now 6e364bb7)

This is an automated email from the ASF dual-hosted git repository.

pengzheng pushed a change to branch hotfix/system-clock-replace
in repository https://gitbox.apache.org/repos/asf/celix.git


      at 6e364bb7 Use std::chrono::steady_clock to handle backward system clock adjustments.

This branch includes the following new commits:

     new 6e364bb7 Use std::chrono::steady_clock to handle backward system clock adjustments.

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



(celix) 01/01: Use std::chrono::steady_clock to handle backward system clock adjustments.

Posted by pe...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

pengzheng pushed a commit to branch hotfix/system-clock-replace
in repository https://gitbox.apache.org/repos/asf/celix.git

commit 6e364bb705490256fda6a8bfb273bfaf372d00e3
Author: PengZheng <ho...@gmail.com>
AuthorDate: Wed Dec 13 17:36:54 2023 +0800

    Use std::chrono::steady_clock to handle backward system clock adjustments.
---
 libs/framework/include/celix/BundleActivator.h           | 4 ++--
 libs/framework/include/celix/Trackers.h                  | 4 ++--
 libs/framework/include/celix/dm/ServiceDependency_Impl.h | 4 ++--
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/libs/framework/include/celix/BundleActivator.h b/libs/framework/include/celix/BundleActivator.h
index 8fffadeb..17e0a3f9 100644
--- a/libs/framework/include/celix/BundleActivator.h
+++ b/libs/framework/include/celix/BundleActivator.h
@@ -60,9 +60,9 @@ namespace impl {
     template<typename T>
     void waitForExpired(long bndId, std::weak_ptr<celix::BundleContext> &weakCtx, const char *name,
                         std::weak_ptr<T> &observe) {
-        auto start = std::chrono::system_clock::now();
+        auto start = std::chrono::steady_clock::now();
         while (!observe.expired()) {
-            auto now = std::chrono::system_clock::now();
+            auto now = std::chrono::steady_clock::now();
             auto durationInSec = std::chrono::duration_cast<std::chrono::seconds>(now - start);
             if (durationInSec > std::chrono::seconds{5}) {
                 auto msg = std::string{"Cannot destroy bundle "} + std::to_string(bndId) + ". " + name +
diff --git a/libs/framework/include/celix/Trackers.h b/libs/framework/include/celix/Trackers.h
index d965ef54..60df7c86 100644
--- a/libs/framework/include/celix/Trackers.h
+++ b/libs/framework/include/celix/Trackers.h
@@ -424,9 +424,9 @@ namespace celix {
 
         template<typename U>
         void waitForExpired(std::weak_ptr<U> observe, long svcId, const char* objName) {
-            auto start = std::chrono::system_clock::now();
+            auto start = std::chrono::steady_clock::now();
             while (!observe.expired()) {
-                auto now = std::chrono::system_clock::now();
+                auto now = std::chrono::steady_clock::now();
                 auto durationInMilli = std::chrono::duration_cast<std::chrono::milliseconds>(now - start);
                 if (durationInMilli > warningTimoutForNonExpiredSvcObject) {
                     celix_bundleContext_log(cCtx.get(), CELIX_LOG_LEVEL_WARNING, "Cannot remove %s associated with service.id %li, because it is still in use. Current shared_ptr use count is %i\n", objName, svcId, (int)observe.use_count());
diff --git a/libs/framework/include/celix/dm/ServiceDependency_Impl.h b/libs/framework/include/celix/dm/ServiceDependency_Impl.h
index 7712bd83..297e81fc 100644
--- a/libs/framework/include/celix/dm/ServiceDependency_Impl.h
+++ b/libs/framework/include/celix/dm/ServiceDependency_Impl.h
@@ -35,9 +35,9 @@ using namespace celix::dm;
 
 template<typename U>
 inline void BaseServiceDependency::waitForExpired(std::weak_ptr<U> observe, long svcId, const char* observeType) {
-    auto start = std::chrono::system_clock::now();
+    auto start = std::chrono::steady_clock::now();
     while (!observe.expired()) {
-        auto now = std::chrono::system_clock::now();
+        auto now = std::chrono::steady_clock::now();
         auto durationInMilli = std::chrono::duration_cast<std::chrono::milliseconds>(now - start);
         if (durationInMilli > warningTimoutForNonExpiredSvcObject) {
             if (cCmp) {