diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2020-10-13 20:12:38 +0000 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2020-10-13 20:13:37 +0000 |
commit | 33291d95a41eeb9919392805da8b2986188c7014 (patch) | |
tree | 68d671e005d2b7208654865d82e2af0fa1168ed2 | |
parent | cdbaea53fb49e3c41b7788f2519d34cd971dad07 (diff) |
Verify that atomic duration time_point is lock free.
-rw-r--r-- | vespalib/src/tests/time/time_test.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/vespalib/src/tests/time/time_test.cpp b/vespalib/src/tests/time/time_test.cpp index 95341219258..c1e73728485 100644 --- a/vespalib/src/tests/time/time_test.cpp +++ b/vespalib/src/tests/time/time_test.cpp @@ -4,6 +4,7 @@ #include <vespa/vespalib/gtest/gtest.h> #include <cinttypes> #include <thread> +#include <atomic> using namespace vespalib; @@ -17,6 +18,11 @@ TEST(TimeTest, system_time_is_compatible_with_system_clock) { (void) t; } +TEST(TimeTest, atomic_duration_is_lock_free) { + static_assert(std::atomic<duration>::is_always_lock_free, "std::atomic<duration> should be atomic"); + static_assert(std::atomic<steady_time>::is_always_lock_free, "std::atomic<steady_time> should be atomic"); +} + TEST(TimeTest, timer_can_measure_elapsed_time) { Timer timer; std::this_thread::sleep_for(10ms); |