diff options
4 files changed, 15 insertions, 10 deletions
diff --git a/vespalib/src/tests/signalhandler/my_shared_library.cpp b/vespalib/src/tests/signalhandler/my_shared_library.cpp index 4b7593d863c..97c03208213 100644 --- a/vespalib/src/tests/signalhandler/my_shared_library.cpp +++ b/vespalib/src/tests/signalhandler/my_shared_library.cpp @@ -8,10 +8,12 @@ // Could have used a single std::barrier<no op functor> here, but when using explicit // phase latches it sort of feels like the semantics are more immediately obvious. -void my_cool_function(std::latch& arrival_latch, std::latch& departure_latch) { - arrival_latch.arrive_and_wait(); +void my_cool_function(vespalib::CountDownLatch& arrival_latch, vespalib::CountDownLatch& departure_latch) { + arrival_latch.countDown(); + arrival_latch.await(); // Twiddle thumbs in departure latch until main test thread has dumped our stack - departure_latch.arrive_and_wait(); + departure_latch.countDown(); + departure_latch.await(); asm(""); // Dear GCC; really, really don't inline this function. It's clobberin' time! } diff --git a/vespalib/src/tests/signalhandler/my_shared_library.h b/vespalib/src/tests/signalhandler/my_shared_library.h index e48a6d91a4f..4a1b259981b 100644 --- a/vespalib/src/tests/signalhandler/my_shared_library.h +++ b/vespalib/src/tests/signalhandler/my_shared_library.h @@ -1,8 +1,8 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include <vespa/vespalib/stllike/string.h> -#include <latch> +#include <vespa/vespalib/util/count_down_latch.h> -void my_cool_function(std::latch&, std::latch&) __attribute__((noinline)); +void my_cool_function(vespalib::CountDownLatch&, vespalib::CountDownLatch&) __attribute__((noinline)); vespalib::string my_totally_tubular_and_groovy_function() __attribute__((noinline)); diff --git a/vespalib/src/tests/signalhandler/signalhandler_test.cpp b/vespalib/src/tests/signalhandler/signalhandler_test.cpp index 8871a985fed..4aeffd27b89 100644 --- a/vespalib/src/tests/signalhandler/signalhandler_test.cpp +++ b/vespalib/src/tests/signalhandler/signalhandler_test.cpp @@ -1,10 +1,10 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include "my_shared_library.h" +#include <vespa/vespalib/util/count_down_latch.h> #include <vespa/vespalib/util/signalhandler.h> #include <vespa/vespalib/gtest/gtest.h> #include <gmock/gmock.h> -#include <latch> #include <thread> #include <unistd.h> @@ -38,18 +38,20 @@ TEST(SignalHandlerTest, signal_handler_can_intercept_hooked_signals) TEST(SignalHandlerTest, can_dump_stack_of_another_thread) { - std::latch arrival_latch(2); - std::latch departure_latch(2); + vespalib::CountDownLatch arrival_latch(2); + vespalib::CountDownLatch departure_latch(2); std::thread t([&]{ my_cool_function(arrival_latch, departure_latch); }); - arrival_latch.arrive_and_wait(); + arrival_latch.countDown(); + arrival_latch.await(); auto trace = SignalHandler::get_cross_thread_stack_trace(t.native_handle()); EXPECT_THAT(trace, HasSubstr("my_cool_function")); - departure_latch.arrive_and_wait(); + departure_latch.countDown(); + departure_latch.await(); t.join(); } diff --git a/vespalib/src/vespa/vespalib/util/signalhandler.cpp b/vespalib/src/vespa/vespalib/util/signalhandler.cpp index 68368269c59..d9e59ed6688 100644 --- a/vespalib/src/vespa/vespalib/util/signalhandler.cpp +++ b/vespalib/src/vespa/vespalib/util/signalhandler.cpp @@ -11,6 +11,7 @@ #include <atomic> #include <cassert> #include <chrono> +#include <mutex> #include <thread> #include <typeinfo> |