Verify that atomic duration time_point is lock free.
#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);
