Hello community, here is the log from the commit of package snapper for openSUSE:Factory checked in at 2015-01-29 09:54:33 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/snapper (Old) and /work/SRC/openSUSE:Factory/.snapper.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "snapper" Changes: -------- --- /work/SRC/openSUSE:Factory/snapper/snapper.changes 2015-01-23 16:17:59.000000000 +0100 +++ /work/SRC/openSUSE:Factory/.snapper.new/snapper.changes 2015-01-29 09:54:36.000000000 +0100 @@ -1,0 +2,5 @@ +Tue Jan 27 12:31:45 CET 2015 - [email protected] + +- use C++11 chrono::steady_clock + +------------------------------------------------------------------- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ snapper-0.2.5.tar.bz2 ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/snapper-0.2.5/dbus/DBusMainLoop.cc new/snapper-0.2.5/dbus/DBusMainLoop.cc --- old/snapper-0.2.5/dbus/DBusMainLoop.cc 2014-06-03 18:58:43.000000000 +0200 +++ new/snapper-0.2.5/dbus/DBusMainLoop.cc 2015-01-27 14:25:38.000000000 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) [2012-2014] Novell, Inc. + * Copyright (c) [2012-2015] Novell, Inc. * * All Rights Reserved. * @@ -22,7 +22,6 @@ #include <unistd.h> #include <poll.h> -#include <time.h> #include "DBusMainLoop.h" @@ -106,17 +105,16 @@ } } - int timeout = periodic_timeout(); + milliseconds timeout = periodic_timeout(); - if (idle_timeout >= 0) + if (idle_timeout.count() >= 0) { - int time_left = last_action - monotonic_clock() + idle_timeout; - - if (timeout > time_left * 1000 || timeout == -1) - timeout = time_left * 1000; + steady_clock::duration time_left = idle_for() + idle_timeout; + if (timeout > time_left || timeout.count() < 0) + timeout = duration_cast<milliseconds>(time_left); } - int r = poll(&pollfds[0], pollfds.size(), timeout); + int r = poll(&pollfds[0], pollfds.size(), timeout.count()); if (r == -1) throw FatalException(); @@ -165,11 +163,10 @@ dispatch_incoming(msg); } - if (idle_timeout >= 0) + if (idle_timeout.count() >= 0) { - int time_left = last_action - monotonic_clock() + idle_timeout; - - if (time_left <= 0) + steady_clock::duration time_left = idle_for() + idle_timeout; + if (time_left.count() <= 0) break; } } @@ -177,16 +174,23 @@ void - MainLoop::set_idle_timeout(int s) + MainLoop::set_idle_timeout(milliseconds idle_timeout) { - idle_timeout = s; + MainLoop::idle_timeout = idle_timeout; } void MainLoop::reset_idle_count() { - last_action = monotonic_clock(); + last_action = steady_clock::now(); + } + + + milliseconds + MainLoop::idle_for() const + { + return duration_cast<milliseconds>(last_action - steady_clock::now()); } @@ -341,13 +345,4 @@ } } - - time_t - DBus::MainLoop::monotonic_clock() - { - struct timespec tmp; - clock_gettime(CLOCK_MONOTONIC, &tmp); - return tmp.tv_sec; - } - } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/snapper-0.2.5/dbus/DBusMainLoop.h new/snapper-0.2.5/dbus/DBusMainLoop.h --- old/snapper-0.2.5/dbus/DBusMainLoop.h 2014-06-03 18:58:43.000000000 +0200 +++ new/snapper-0.2.5/dbus/DBusMainLoop.h 2015-01-27 14:25:38.000000000 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) [2012-2014] Novell, Inc. + * Copyright (c) [2012-2015] Novell, Inc. * * All Rights Reserved. * @@ -25,6 +25,7 @@ #include <dbus/dbus.h> +#include <chrono> #include "DBusConnection.h" @@ -32,6 +33,9 @@ namespace DBus { + using namespace std::chrono; + + class MainLoop : public Connection { public: @@ -41,7 +45,7 @@ void run(); - void set_idle_timeout(int s); + void set_idle_timeout(milliseconds idle_timeout); void reset_idle_count(); void add_client_match(const string& name); @@ -50,7 +54,7 @@ virtual void method_call(Message& message) = 0; virtual void signal(Message& message) = 0; virtual void client_disconnected(const string& name) = 0; - virtual int periodic_timeout() = 0; + virtual milliseconds periodic_timeout() = 0; virtual void periodic() = 0; private: @@ -94,10 +98,10 @@ void dispatch_incoming(Message& message); - int idle_timeout; - time_t last_action; + milliseconds idle_for() const; - static time_t monotonic_clock(); + milliseconds idle_timeout; + steady_clock::time_point last_action; }; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/snapper-0.2.5/server/Client.cc new/snapper-0.2.5/server/Client.cc --- old/snapper-0.2.5/server/Client.cc 2015-01-12 13:50:07.000000000 +0100 +++ new/snapper-0.2.5/server/Client.cc 2015-01-27 14:25:38.000000000 +0100 @@ -1352,7 +1352,7 @@ { s << ", loaded"; if (it->use_count() == 0) - s << ", unused for " << it->unused_for() << "s"; + s << ", unused for " << duration_cast<milliseconds>(it->unused_for()).count() << "ms"; else s << ", use count " << it->use_count(); } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/snapper-0.2.5/server/MetaSnapper.cc new/snapper-0.2.5/server/MetaSnapper.cc --- old/snapper-0.2.5/server/MetaSnapper.cc 2015-01-12 13:50:07.000000000 +0100 +++ new/snapper-0.2.5/server/MetaSnapper.cc 2015-01-27 14:25:38.000000000 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) [2012-2014] Novell, Inc. + * Copyright (c) [2012-2015] Novell, Inc. * * All Rights Reserved. * @@ -35,7 +35,7 @@ RefCounter::RefCounter() - : counter(0), last_used(monotonic_time()) + : counter(0), last_used(steady_clock::now()) { } @@ -57,7 +57,7 @@ assert(counter > 0); if (--counter == 0) - last_used = monotonic_time(); + last_used = steady_clock::now(); return counter; } @@ -68,7 +68,7 @@ { boost::lock_guard<boost::mutex> lock(mutex); - last_used = monotonic_time(); + last_used = steady_clock::now(); } @@ -81,27 +81,15 @@ } -int +milliseconds RefCounter::unused_for() const { boost::lock_guard<boost::mutex> lock(mutex); if (counter != 0) - return 0; - - struct timespec tmp; - clock_gettime(CLOCK_MONOTONIC, &tmp); - - return tmp.tv_sec - last_used; -} - + return milliseconds(0); -time_t -RefCounter::monotonic_time() -{ - struct timespec tmp; - clock_gettime(CLOCK_MONOTONIC, &tmp); - return tmp.tv_sec; + return duration_cast<milliseconds>(steady_clock::now() - last_used); } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/snapper-0.2.5/server/MetaSnapper.h new/snapper-0.2.5/server/MetaSnapper.h --- old/snapper-0.2.5/server/MetaSnapper.h 2014-08-01 09:54:24.000000000 +0200 +++ new/snapper-0.2.5/server/MetaSnapper.h 2015-01-27 14:25:38.000000000 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) [2012-2013] Novell, Inc. + * Copyright (c) [2012-2015] Novell, Inc. * * All Rights Reserved. * @@ -24,12 +24,14 @@ #define SNAPPER_META_SNAPPER_H +#include <chrono> #include <boost/thread.hpp> #include <snapper/Snapper.h> using namespace std; +using namespace std::chrono; using namespace snapper; @@ -44,17 +46,15 @@ void update_use_time(); int use_count() const; - int unused_for() const; + milliseconds unused_for() const; private: - static time_t monotonic_time(); - mutable boost::mutex mutex; int counter; - time_t last_used; + steady_clock::time_point last_used; }; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/snapper-0.2.5/server/snapperd.cc new/snapper-0.2.5/server/snapperd.cc --- old/snapper-0.2.5/server/snapperd.cc 2014-01-29 16:48:30.000000000 +0100 +++ new/snapper-0.2.5/server/snapperd.cc 2015-01-27 14:25:38.000000000 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012 Novell, Inc. + * Copyright (c) [2012-2015] Novell, Inc. * * All Rights Reserved. * @@ -37,8 +37,8 @@ using namespace std; -const int idle_time = 60; -const int snapper_cleanup_time = 30; +const seconds idle_time(60); +const seconds snapper_cleanup_time(30); bool log_stdout = false; bool log_debug = false; @@ -55,7 +55,7 @@ void signal(DBus::Message& message); void client_disconnected(const string& name); void periodic(); - int periodic_timeout(); + milliseconds periodic_timeout(); }; @@ -93,7 +93,7 @@ y2deb("client connected invisible '" << msg.get_sender() << "'"); add_client_match(msg.get_sender()); client = clients.add(msg.get_sender()); - set_idle_timeout(-1); + set_idle_timeout(seconds(-1)); } client->add_task(*this, msg); @@ -146,22 +146,22 @@ } -int +milliseconds MyMainLoop::periodic_timeout() { boost::unique_lock<boost::shared_mutex> lock(big_mutex); if (clients.has_zombies()) - return 1000; + return seconds(1); if (!backgrounds.empty()) - return 1000; + return seconds(1); for (MetaSnappers::const_iterator it = meta_snappers.begin(); it != meta_snappers.end(); ++it) if (it->is_loaded() && it->use_count() == 0) - return 1000; + return seconds(1); - return -1; + return seconds(-1); } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/snapper-0.2.5/snapper/AppUtil.cc new/snapper-0.2.5/snapper/AppUtil.cc --- old/snapper-0.2.5/snapper/AppUtil.cc 2014-10-10 12:40:06.000000000 +0200 +++ new/snapper-0.2.5/snapper/AppUtil.cc 2015-01-27 14:25:38.000000000 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) [2004-2014] Novell, Inc. + * Copyright (c) [2004-2015] Novell, Inc. * * All Rights Reserved. * @@ -357,25 +357,22 @@ StopWatch::StopWatch() + : start_time(chrono::steady_clock::now()) { - gettimeofday(&start_tv, NULL); } double StopWatch::read() const { - struct timeval stop_tv; - gettimeofday(&stop_tv, NULL); - - struct timeval tv; - timersub(&stop_tv, &start_tv, &tv); - - return double(tv.tv_sec) + (double)(tv.tv_usec) / 1000000.0; + chrono::steady_clock::time_point stop_time = chrono::steady_clock::now(); + chrono::steady_clock::duration duration = stop_time - start_time; + return chrono::duration<double>(duration).count(); } - std::ostream& operator<<(std::ostream& s, const StopWatch& sw) + std::ostream& + operator<<(std::ostream& s, const StopWatch& sw) { boost::io::ios_all_saver ias(s); return s << fixed << sw.read() << "s"; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/snapper-0.2.5/snapper/AppUtil.h new/snapper-0.2.5/snapper/AppUtil.h --- old/snapper-0.2.5/snapper/AppUtil.h 2014-08-01 10:12:17.000000000 +0200 +++ new/snapper-0.2.5/snapper/AppUtil.h 2015-01-27 14:25:38.000000000 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) [2004-2014] Novell, Inc. + * Copyright (c) [2004-2015] Novell, Inc. * * All Rights Reserved. * @@ -34,6 +34,7 @@ #include <map> #include <vector> #include <stdexcept> +#include <chrono> namespace snapper @@ -103,7 +104,7 @@ protected: - struct timeval start_tv; + std::chrono::steady_clock::time_point start_time; }; -- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
