diff options
author | Lorry Tar Creator <lorry-tar-importer@baserock.org> | 2015-04-08 03:09:47 +0000 |
---|---|---|
committer | <> | 2015-05-05 14:37:32 +0000 |
commit | f2541bb90af059680aa7036f315f052175999355 (patch) | |
tree | a5b214744b256f07e1dc2bd7273035a7808c659f /libs/thread/test/test_9856.cpp | |
parent | ed232fdd34968697a68783b3195b1da4226915b5 (diff) | |
download | boost-tarball-master.tar.gz |
Imported from /home/lorry/working-area/delta_boost-tarball/boost_1_58_0.tar.bz2.HEADboost_1_58_0master
Diffstat (limited to 'libs/thread/test/test_9856.cpp')
-rw-r--r-- | libs/thread/test/test_9856.cpp | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/libs/thread/test/test_9856.cpp b/libs/thread/test/test_9856.cpp new file mode 100644 index 000000000..918d232d5 --- /dev/null +++ b/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>10) + { + std::cerr << "This exceeds 10%, so failing the test." << std::endl; + return 1; + } + return 0; +}
\ No newline at end of file |