aboutsummaryrefslogtreecommitdiffstats
path: root/test/test_latch01.cpp
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2021-12-05 22:08:40 +0100
committerSven Gothel <[email protected]>2021-12-05 22:08:40 +0100
commit244f87b20b82ea87f868ba5717777744816668c2 (patch)
treef8c4423661f760cc5b6dda72b6c43492d58611ab /test/test_latch01.cpp
parentd7b5331897b5dedab9269de65c5e390009a837c0 (diff)
Fix test_latch01.cpp: Thread function something() needs to use atomic increment to avoid data race conditions w/ concurrent threads
Diffstat (limited to 'test/test_latch01.cpp')
-rw-r--r--test/test_latch01.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/test/test_latch01.cpp b/test/test_latch01.cpp
index d4bd2bb..63cf836 100644
--- a/test/test_latch01.cpp
+++ b/test/test_latch01.cpp
@@ -29,7 +29,8 @@
#include <thread>
#include <pthread.h>
-#define CATCH_CONFIG_MAIN
+#define CATCH_CONFIG_RUNNER
+// #define CATCH_CONFIG_MAIN
#include <catch2/catch_amalgamated.hpp>
#include <jau/test/catch2_ext.hpp>
@@ -42,7 +43,7 @@ class TestLatch01 {
jau::relaxed_atomic_int my_counter = 0;
void something(jau::latch& l) {
- my_counter = my_counter + 1;
+ my_counter++;
l.count_down();
}