summaryrefslogtreecommitdiffstats
path: root/fastos
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2019-11-20 14:44:16 +0000
committerHenning Baldersheim <balder@yahoo-inc.com>2019-11-20 14:44:16 +0000
commit3c9a7ec70c36bf238765588859fa7b6672a9ff8a (patch)
treec5c591a2ba23a93f2eaffcfaee01a774cc616997 /fastos
parenta60135f773594236ac2e4228773e2a18a181f0a3 (diff)
Simplify.
Diffstat (limited to 'fastos')
-rw-r--r--fastos/src/vespa/fastos/timestamp.cpp20
1 files changed, 9 insertions, 11 deletions
diff --git a/fastos/src/vespa/fastos/timestamp.cpp b/fastos/src/vespa/fastos/timestamp.cpp
index c7f269b59b9..8428de9968e 100644
--- a/fastos/src/vespa/fastos/timestamp.cpp
+++ b/fastos/src/vespa/fastos/timestamp.cpp
@@ -97,22 +97,20 @@ StopWatch::restart() {
TimeStamp
StopWatch::elapsed() const {
- TimeStamp diff(steady_now() - _startTime);
- return (diff > 0) ? diff : TimeStamp(0);
+ return (steady_now() - _startTime);
}
void
StopWatch::waitAtLeast(std::chrono::microseconds us, bool busyWait) {
- steady_clock::time_point startTime = steady_clock::now();
- steady_clock::time_point deadline = startTime + us;
- while (steady_clock::now() < deadline) {
- if (busyWait) {
- for (int i = 0; i < 1000; i++)
- ;
- } else {
- microseconds rem = (us - duration_cast<microseconds>(steady_clock::now() - startTime));
- std::this_thread::sleep_for(rem);
+ if (busyWait) {
+ steady_clock::time_point deadline = steady_clock::now() + us;
+ while (steady_clock::now() < deadline) {
+ if (busyWait) {
+ for (int i = 0; i < 1000; i++) { }
+ }
}
+ } else {
+ std::this_thread::sleep_for(us);
}
}