From 59b5ff29c961332f9deafd6300cda9ce2c7be5c1 Mon Sep 17 00:00:00 2001 From: Egor Tensin Date: Wed, 21 Oct 2020 05:27:00 +0300 Subject: shmem_tests: notify_all outside of lock --- test/unit_tests/shmem.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/test/unit_tests/shmem.cpp b/test/unit_tests/shmem.cpp index 26f1389..4220386 100644 --- a/test/unit_tests/shmem.cpp +++ b/test/unit_tests/shmem.cpp @@ -30,21 +30,21 @@ struct DataStruct { void setter1_main() { const auto data_struct = SharedObject::open(shmem_name); - std::unique_lock lck{data_struct->mtx}; - BOOST_TEST_MESSAGE(data_struct.ptr()); - - data_struct->cv.wait(lck, [&]() { return data_struct->data == main_data; }); - data_struct->data = setter1_data; + { + std::unique_lock lck{data_struct->mtx}; + data_struct->cv.wait(lck, [&]() { return data_struct->data == main_data; }); + data_struct->data = setter1_data; + } data_struct->cv.notify_all(); } void setter2_main() { auto data_struct = SharedObject::open(shmem_name); - std::unique_lock lck{data_struct->mtx}; - BOOST_TEST_MESSAGE(data_struct.ptr()); - - data_struct->cv.wait(lck, [&]() { return data_struct->data == setter1_data; }); - data_struct->data = setter2_data; + { + std::unique_lock lck{data_struct->mtx}; + data_struct->cv.wait(lck, [&]() { return data_struct->data == setter1_data; }); + data_struct->data = setter2_data; + } data_struct->cv.notify_all(); } -- cgit v1.2.3