summaryrefslogtreecommitdiffstats
path: root/src/boost/libs/thread/test/test_9856.cpp
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 18:45:59 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 18:45:59 +0000
commit19fcec84d8d7d21e796c7624e521b60d28ee21ed (patch)
tree42d26aa27d1e3f7c0b8bd3fd14e7d7082f5008dc /src/boost/libs/thread/test/test_9856.cpp
parentInitial commit. (diff)
downloadceph-upstream.tar.xz
ceph-upstream.zip
Adding upstream version 16.2.11+ds.upstream/16.2.11+dsupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/boost/libs/thread/test/test_9856.cpp')
-rw-r--r--src/boost/libs/thread/test/test_9856.cpp29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/boost/libs/thread/test/test_9856.cpp b/src/boost/libs/thread/test/test_9856.cpp
new file mode 100644
index 000000000..b7dcc6e37
--- /dev/null
+++ b/src/boost/libs/thread/test/test_9856.cpp
@@ -0,0 +1,29 @@
+#include "boost/atomic.hpp"
+#include "boost/thread.hpp"
+#include <iostream>
+
+using namespace boost;
+
+int main() {
+ atomic<size_t> total(0), failures(0);
+
+#pragma omp parallel shared(total, failures) num_threads(1000)
+ {
+ mutex mtx;
+ condition_variable cond;
+ unique_lock<mutex> lk(mtx);
+ for (int i = 0; i < 500; i++) {
+ ++total;
+ if (cv_status::timeout != cond.wait_for(lk, chrono::milliseconds(10)))
+ ++failures;
+ }
+ }
+ if(failures)
+ std::cout << "There were " << failures << " failures out of " << total << " timed waits." << std::endl;
+ if((100*failures)/total>40)
+ {
+ std::cerr << "This exceeds 10%, so failing the test." << std::endl;
+ return 1;
+ }
+ return 0;
+}