diff options
author | paolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4> | 2011-10-28 14:33:21 +0000 |
---|---|---|
committer | paolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4> | 2011-10-28 14:33:21 +0000 |
commit | 03ed186a28c3d28ca06e2f91010f347b1f6f84a9 (patch) | |
tree | 32e260fcf2b9106d93f77ef6fc4edce2e628a09f /libstdc++-v3/testsuite/30_threads | |
parent | d6e57d851bcfe51a361ae8fe423dbab6c0add539 (diff) | |
download | gcc-03ed186a28c3d28ca06e2f91010f347b1f6f84a9.tar.gz |
2011-10-28 Paolo Carlini <paolo.carlini@oracle.com>
* testsuite/30_threads/condition_variable_any/50862.cc: Trivial
formatting fixes.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@180617 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3/testsuite/30_threads')
-rw-r--r-- | libstdc++-v3/testsuite/30_threads/condition_variable_any/50862.cc | 50 |
1 files changed, 27 insertions, 23 deletions
diff --git a/libstdc++-v3/testsuite/30_threads/condition_variable_any/50862.cc b/libstdc++-v3/testsuite/30_threads/condition_variable_any/50862.cc index 9ca008681b6..b85a5e13626 100644 --- a/libstdc++-v3/testsuite/30_threads/condition_variable_any/50862.cc +++ b/libstdc++-v3/testsuite/30_threads/condition_variable_any/50862.cc @@ -41,8 +41,8 @@ int main() std::mutex m; std::condition_variable_any cond; - unsigned int product=0; - const unsigned int count=10; + unsigned int product = 0; + const unsigned int count = 10; // writing to stream causes timing changes which makes deadlock easier // to reproduce - do not remove @@ -50,27 +50,31 @@ int main() // create consumers std::array<scoped_thread, 2> threads; - for(size_t i=0; i<threads.size(); ++i) - threads[i].t = std::thread( [&] { - for(unsigned int i=0; i<count; ++i) - { - std::this_thread::yield(); - Lock lock(m); - while(product==0) - cond.wait(lock); - out << "got product " << std::this_thread::get_id() << ' ' << product << std::endl; - --product; - } - } ); + for (std::size_t i = 0; i < threads.size(); ++i) + threads[i].t + = std::thread( [&] + { + for (unsigned int i = 0; i < count; ++i) + { + std::this_thread::yield(); + Lock lock(m); + while(product == 0) + cond.wait(lock); + out << "got product " + << std::this_thread::get_id() + << ' ' << product << std::endl; + --product; + } + } ); // single producer - for(size_t i=0; i<threads.size()*count; ++i) - { - std::this_thread::yield(); - Lock lock(m); - ++product; - out << "setting product " << std::this_thread::get_id() << ' ' << product << std::endl; - cond.notify_one(); - } - + for (std::size_t i = 0; i < threads.size() * count; ++i) + { + std::this_thread::yield(); + Lock lock(m); + ++product; + out << "setting product " << std::this_thread::get_id() + << ' ' << product << std::endl; + cond.notify_one(); + } } |