diff options
author | Alex Chronopoulos <[email protected]> | 2017-06-02 17:40:29 +0300 |
---|---|---|
committer | Matthew Gregan <[email protected]> | 2017-06-06 15:46:05 +1200 |
commit | af50e9c96fa2ff2064088b9274f491853da9257b (patch) | |
tree | 405937a56c579d1c17b5ae5cc11e96aab382a2df /test/test_deadlock.cpp | |
parent | c3ebb000f2355ca2b760eebd2fbde806482c3188 (diff) | |
download | cubeb-af50e9c96fa2ff2064088b9274f491853da9257b.tar.gz cubeb-af50e9c96fa2ff2064088b9274f491853da9257b.zip |
audiounit: clear tsan warnings
Diffstat (limited to 'test/test_deadlock.cpp')
-rw-r--r-- | test/test_deadlock.cpp | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/test/test_deadlock.cpp b/test/test_deadlock.cpp index 64ca6e7..42301ac 100644 --- a/test/test_deadlock.cpp +++ b/test/test_deadlock.cpp @@ -52,6 +52,7 @@ #include <stdexcept> // for std::logic_error #include <string> // for std::string #include <unistd.h> // for sleep, usleep +#include <atomic> // for std::atomic // The signal alias for calling our thread killer. #define CALL_THREAD_KILLER SIGUSR1 @@ -61,7 +62,7 @@ bool killed = false; // This indicator will become true when the assigned task is done. -bool task_done = false; +std::atomic<bool> task_done{ false }; // Indicating the data callback is fired or not. bool called = false; @@ -69,7 +70,7 @@ bool called = false; // Toggle to true when running data callback. Before data callback gets // the mutex for cubeb context, it toggles back to false. // The task to get channel layout should be executed when this is true. -bool callbacking_before_getting_context = false; +std::atomic<bool> callbacking_before_getting_context{ false }; owned_critical_section context_mutex; cubeb * context = nullptr; @@ -242,11 +243,11 @@ TEST(cubeb, run_deadlock_test) ASSERT_TRUE(called); - fprintf(stderr, "\n%sDeadlock detected!\n", (called && !task_done) ? "" : "No "); + fprintf(stderr, "\n%sDeadlock detected!\n", (called && !task_done.load()) ? "" : "No "); // Check the task is killed by ourselves if deadlock happends. // Otherwise, thread_killer should not be triggered. - ASSERT_NE(task_done, killed); + ASSERT_NE(task_done.load(), killed); - ASSERT_TRUE(task_done); + ASSERT_TRUE(task_done.load()); } |