diff options
author | ljrittle <ljrittle@138bc75d-0d04-0410-961f-82ee72b054a4> | 2002-01-26 03:26:14 +0000 |
---|---|---|
committer | ljrittle <ljrittle@138bc75d-0d04-0410-961f-82ee72b054a4> | 2002-01-26 03:26:14 +0000 |
commit | 8f73d499a9952fb99dc318e4e4aa4892f6ff636b (patch) | |
tree | dde8f5e870c2080b8cb7675245ea1963794eab6a /libstdc++-v3 | |
parent | aae061fde2843546ed8ff13a4e58cec9d0f5f47d (diff) | |
download | gcc-8f73d499a9952fb99dc318e4e4aa4892f6ff636b.tar.gz |
* testsuite/thread/pthread1.cc: Use one condition variable
per predicate instead of tricky use of one condition variable.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@49239 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3')
-rw-r--r-- | libstdc++-v3/ChangeLog | 5 | ||||
-rw-r--r-- | libstdc++-v3/testsuite/thread/pthread1.cc | 20 |
2 files changed, 15 insertions, 10 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 47e43bdbf47..3370daeff9f 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,8 @@ +2002-01-25 Loren Rittle <ljrittle@acm.org> + + * testsuite/thread/pthread1.cc: Use one condition variable + per predicate instead of tricky use of one condition variable. + 2002-01-25 Benjamin Kosnik <bkoz@redhat.com> * include/bits/fstream.tcc (filebuf::close()): Fix close for input diff --git a/libstdc++-v3/testsuite/thread/pthread1.cc b/libstdc++-v3/testsuite/thread/pthread1.cc index b8f522655cc..71afefcc758 100644 --- a/libstdc++-v3/testsuite/thread/pthread1.cc +++ b/libstdc++-v3/testsuite/thread/pthread1.cc @@ -48,19 +48,19 @@ public: task_queue () { pthread_mutex_init (&fooLock, NULL); - pthread_cond_init (&fooCond, NULL); + pthread_cond_init (&fooCond1, NULL); + pthread_cond_init (&fooCond2, NULL); } ~task_queue () { pthread_mutex_destroy (&fooLock); - pthread_cond_destroy (&fooCond); + pthread_cond_destroy (&fooCond1); + pthread_cond_destroy (&fooCond2); } list<int> foo; pthread_mutex_t fooLock; - // This code uses a special case that allows us to use just one - // condition variable - in general, don't use this idiom unless you - // know what you are doing. ;-) - pthread_cond_t fooCond; + pthread_cond_t fooCond1; + pthread_cond_t fooCond2; }; void* @@ -72,9 +72,9 @@ produce (void* t) { pthread_mutex_lock (&tq.fooLock); while (tq.foo.size () >= max_size) - pthread_cond_wait (&tq.fooCond, &tq.fooLock); + pthread_cond_wait (&tq.fooCond1, &tq.fooLock); tq.foo.push_back (num++); - pthread_cond_signal (&tq.fooCond); + pthread_cond_signal (&tq.fooCond2); pthread_mutex_unlock (&tq.fooLock); } return 0; @@ -89,11 +89,11 @@ consume (void* t) { pthread_mutex_lock (&tq.fooLock); while (tq.foo.size () == 0) - pthread_cond_wait (&tq.fooCond, &tq.fooLock); + pthread_cond_wait (&tq.fooCond2, &tq.fooLock); if (tq.foo.front () != num++) abort (); tq.foo.pop_front (); - pthread_cond_signal (&tq.fooCond); + pthread_cond_signal (&tq.fooCond1); pthread_mutex_unlock (&tq.fooLock); } return 0; |