mirror of
git://gcc.gnu.org/git/gcc.git
synced 2025-02-22 10:49:48 +08:00
50862.cc: Trivial formatting fixes.
2011-10-28 Paolo Carlini <paolo.carlini@oracle.com> * testsuite/30_threads/condition_variable_any/50862.cc: Trivial formatting fixes. From-SVN: r180617
This commit is contained in:
parent
a53f352313
commit
e8a25ac83c
@ -1,3 +1,21 @@
|
||||
2011-10-28 Paolo Carlini <paolo.carlini@oracle.com>
|
||||
|
||||
* testsuite/30_threads/condition_variable_any/50862.cc: Trivial
|
||||
formatting fixes.
|
||||
|
||||
2011-10-28 Paolo Carlini <paolo.carlini@oracle.com>
|
||||
|
||||
* testsuite/23_containers/unordered_map/operations/count.cc: New.
|
||||
* testsuite/23_containers/multimap/operations/count.cc: Likewise.
|
||||
* testsuite/23_containers/set/operations/count.cc: Likewise.
|
||||
* testsuite/23_containers/unordered_multimap/operations/count.cc:
|
||||
Likewise.
|
||||
* testsuite/23_containers/unordered_set/operations/count.cc: Likewise.
|
||||
* testsuite/23_containers/multiset/operations/count.cc: Likewise.
|
||||
* testsuite/23_containers/unordered_multiset/operations/count.cc:
|
||||
Likewise.
|
||||
* testsuite/23_containers/map/operations/count.cc: Likewise.
|
||||
|
||||
2011-10-28 Richard B. Kreckel <kreckel@ginac.de>
|
||||
|
||||
* include/std/complex (__complex_acosh): Just use '< _Tp()'.
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user