summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorchclvl <chclvl@users.sourceforge.net>2021-10-15 17:43:55 +0200
committerchclvl <chclvl@users.sourceforge.net>2021-10-15 17:43:55 +0200
commitfe5ca2fd155d5f292a4fc5a098ec5cbf0da2816f (patch)
tree4b215b1e56776383ca5f87c164832cd76b734a23
parent460f2f98a0b567950b9c0eae29ddd137cdb13318 (diff)
parentc871790a8ffaf86dcc42889baf33422fb84c552c (diff)
downloaddbus-c++-fe5ca2fd155d5f292a4fc5a098ec5cbf0da2816f.tar.gz
Merge branch '#22_Using_gettimeofday_for_timeouts' into develop
# Conflicts: # .gitignore
-rw-r--r--.gitignore2
-rw-r--r--src/eventloop.cpp12
2 files changed, 7 insertions, 7 deletions
diff --git a/.gitignore b/.gitignore
index ec61622..2a8b8cf 100644
--- a/.gitignore
+++ b/.gitignore
@@ -25,7 +25,6 @@ tools/Makefile.in
/config.h
/config.log
/config.status
-/data/Makefile
/dbus-c++-1-uninstalled.pc
/dbus-c++-1.pc
/dbus-c++-ecore-1-uninstalled.pc
@@ -1284,3 +1283,4 @@ tools/Makefile.in
/tools/introspect.o
/tools/xml.o
/tools/xml2cpp.o
+/data/Makefile
diff --git a/src/eventloop.cpp b/src/eventloop.cpp
index f622812..3fcee95 100644
--- a/src/eventloop.cpp
+++ b/src/eventloop.cpp
@@ -36,16 +36,16 @@
using namespace DBus;
using namespace std;
-static double millis(timeval tv)
+static double millis(struct timespec ts)
{
- return (tv.tv_sec * 1000.0 + tv.tv_usec / 1000.0);
+ return (ts.tv_sec * 1000.0 + ts.tv_nsec / 1000000.0);
}
DefaultTimeout::DefaultTimeout(int interval, bool repeat, DefaultMainLoop *ed)
: _enabled(true), _interval(interval), _repeat(repeat), _expiration(0), _data(0), _disp(ed)
{
- timeval now;
- gettimeofday(&now, NULL);
+ struct timespec now;
+ clock_gettime (CLOCK_MONOTONIC_RAW, &now);
_expiration = millis(now) + interval;
@@ -205,8 +205,8 @@ void DefaultMainLoop::dispatch()
poll(fds, nfd, wait_min);
- timeval now;
- gettimeofday(&now, NULL);
+ struct timespec now;
+ clock_gettime (CLOCK_MONOTONIC_RAW, &now);
double now_millis = millis(now);