]> git.ipfire.org Git - thirdparty/snapper.git/commitdiff
- work on dbus interface
authorArvin Schnell <aschnell@suse.de>
Mon, 6 Aug 2012 07:10:50 +0000 (09:10 +0200)
committerArvin Schnell <aschnell@suse.de>
Mon, 6 Aug 2012 07:10:50 +0000 (09:10 +0200)
dbus/DBusMainLoop.cc
dbus/DBusMainLoop.h
server/MetaSnapper.cc
server/MetaSnapper.h

index aafc5f20472ecc8c26b5521a0eec612b66f4e2ca..8ac8da58b89642f8588d713ed0e572b5f808371a 100644 (file)
@@ -90,9 +90,7 @@ namespace DBus
 
            if (idle_timeout >= 0)
            {
-               struct timespec tmp;
-               clock_gettime(CLOCK_MONOTONIC, &tmp);
-               int time_left = last_action - tmp.tv_sec + idle_timeout;
+               int time_left = last_action - monotonic_clock() + idle_timeout;
 
                if (timeout > time_left * 1000 || timeout == -1)
                    timeout = time_left * 1000;
@@ -148,9 +146,7 @@ namespace DBus
 
            if (idle_timeout >= 0)
            {
-               struct timespec tmp;
-               clock_gettime(CLOCK_MONOTONIC, &tmp);
-               int time_left = last_action - tmp.tv_sec + idle_timeout;
+               int time_left = last_action - monotonic_clock() + idle_timeout;
 
                if (time_left <= 0)
                    break;
@@ -169,9 +165,7 @@ namespace DBus
     void
     MainLoop::reset_idle_count()
     {
-       struct timespec tmp;
-       clock_gettime(CLOCK_MONOTONIC, &tmp);
-       last_action = tmp.tv_sec;
+       last_action = monotonic_clock();
     }
 
 
@@ -314,4 +308,13 @@ namespace DBus
        }
     }
 
+
+    time_t
+    DBus::MainLoop::monotonic_clock()
+    {
+       struct timespec tmp;
+       clock_gettime(CLOCK_MONOTONIC, &tmp);
+       return tmp.tv_sec;
+    }
+
 }
index 5ac88010384f053491d886e856d63308df6e7fb5..5492c23b1e18d53b43c17e03ee0fb1e7e623c41a 100644 (file)
@@ -91,6 +91,8 @@ namespace DBus
        int idle_timeout;
        time_t last_action;
 
+       static time_t monotonic_clock();
+
     };
 
 }
index a0ad9315e4b81a3295e7d67ed9f917648100bf7a..bc5d7248a410425f235ebb3d8aa3ac3de58cb48b 100644 (file)
@@ -34,11 +34,8 @@ MetaSnappers meta_snappers;
 
 
 RefCounter::RefCounter()
-    : counter(0)
+    : counter(0), last_used(monotonic_time())
 {
-    struct timespec tmp;
-    clock_gettime(CLOCK_MONOTONIC, &tmp);
-    last_used = tmp.tv_sec;
 }
 
 
@@ -59,11 +56,7 @@ RefCounter::dec_use_count()
     assert(counter > 0);
 
     if (--counter == 0)
-    {
-       struct timespec tmp;
-       clock_gettime(CLOCK_MONOTONIC, &tmp);
-       last_used = tmp.tv_sec;
-    }
+       last_used = monotonic_time();
 
     return counter;
 }
@@ -74,9 +67,7 @@ RefCounter::update_use_time()
 {
     boost::lock_guard<boost::mutex> lock(mutex);
 
-    struct timespec tmp;
-    clock_gettime(CLOCK_MONOTONIC, &tmp);
-    last_used = tmp.tv_sec;
+    last_used = monotonic_time();
 }
 
 
@@ -104,6 +95,15 @@ RefCounter::unused_for() const
 }
 
 
+time_t
+RefCounter::monotonic_time()
+{
+    struct timespec tmp;
+    clock_gettime(CLOCK_MONOTONIC, &tmp);
+    return tmp.tv_sec;
+}
+
+
 bool
 get_user_uid(const char* username, uid_t& uid)
 {
index b73d1c302caf9fa7b2ff5f4691561f985ffc530b..62d78093a9468caab082bbb4bd246fe6f5c0a6b0 100644 (file)
@@ -50,6 +50,8 @@ public:
 
 private:
 
+    static time_t monotonic_time();
+
     mutable boost::mutex mutex;
 
     int counter;