diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2022-03-03 13:53:30 +0000 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2022-03-03 13:53:30 +0000 |
commit | da9cd02f57209a4ad8e456d5bae5c38f2c51592b (patch) | |
tree | 0d10610cdaee43c8c1bc9c341b530ad3278f7a27 /vespalib | |
parent | fc86d2bd7ff710f24d61c124ae9b4e6c7fd835db (diff) |
relative std::this_thread::sleep_for is more efficient than absolute std::this_thread::sleep_until. This is the opposite of std::condition_variable::wait_until/wait_for.
Diffstat (limited to 'vespalib')
-rw-r--r-- | vespalib/src/vespa/vespalib/util/invokeserviceimpl.cpp | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/vespalib/src/vespa/vespalib/util/invokeserviceimpl.cpp b/vespalib/src/vespa/vespalib/util/invokeserviceimpl.cpp index eac84568ec2..c10029b2f58 100644 --- a/vespalib/src/vespa/vespalib/util/invokeserviceimpl.cpp +++ b/vespalib/src/vespa/vespalib/util/invokeserviceimpl.cpp @@ -64,8 +64,7 @@ void InvokeServiceImpl::runLoop() { bool done = false; while ( ! done ) { - const steady_time now = steady_clock::now(); - _now.store(now, std::memory_order_relaxed); + _now.store(steady_clock::now(), std::memory_order_relaxed); { std::lock_guard guard(_lock); for (auto & func: _toInvoke) { @@ -74,7 +73,7 @@ InvokeServiceImpl::runLoop() { done = _closed; } if ( ! done) { - std::this_thread::sleep_until(now + _naptime); + std::this_thread::sleep_for(_naptime); } } |