From 566e00a7c20d0c27ab7bcacf699833ce29a3e12c Mon Sep 17 00:00:00 2001 From: Mike Purvis Date: Mon, 28 Oct 2013 20:22:55 -0400 Subject: [PATCH] Rename now function to timespec_now and timeout_time to expiry, for greater clarity. --- include/serial/impl/unix.h | 4 ++-- src/impl/unix.cc | 16 ++++++++-------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/include/serial/impl/unix.h b/include/serial/impl/unix.h index 9dda1e1..12e693b 100644 --- a/include/serial/impl/unix.h +++ b/include/serial/impl/unix.h @@ -58,8 +58,8 @@ public: uint32_t remaining(); private: - static timespec now(); - timespec timeout_time; + static timespec timespec_now(); + timespec expiry; }; class serial::Serial::SerialImpl { diff --git a/src/impl/unix.cc b/src/impl/unix.cc index 8c62a0e..1ffdc12 100755 --- a/src/impl/unix.cc +++ b/src/impl/unix.cc @@ -52,21 +52,21 @@ using serial::IOException; MillisecondTimer::MillisecondTimer (const uint32_t millis) - : timeout_time(now()) + : expiry(timespec_now()) { - int64_t tv_nsec = timeout_time.tv_nsec + (millis * 1e6); + int64_t tv_nsec = expiry.tv_nsec + (millis * 1e6); if (tv_nsec > 1e9) { - timeout_time.tv_nsec = tv_nsec % (int)1e6; - timeout_time.tv_sec += tv_nsec / (int)1e6; + expiry.tv_nsec = tv_nsec % (int)1e6; + expiry.tv_sec += tv_nsec / (int)1e6; } } uint32_t MillisecondTimer::remaining () { - timespec now_time(now()); - int64_t millis = (timeout_time.tv_sec - now_time.tv_sec) * 1e3; - millis += (timeout_time.tv_nsec - now_time.tv_nsec) / 1e6; + timespec now(timespec_now()); + int64_t millis = (expiry.tv_sec - now.tv_sec) * 1e3; + millis += (expiry.tv_nsec - now.tv_nsec) / 1e6; if (millis <= 0) { throw TimerExpiredException(); } @@ -74,7 +74,7 @@ MillisecondTimer::remaining () } timespec -MillisecondTimer::now () +MillisecondTimer::timespec_now () { timespec time; # ifdef __MACH__ // OS X does not have clock_gettime, use clock_get_time