aboutsummaryrefslogtreecommitdiff
path: root/libstdc++-v3/testsuite/thread
diff options
context:
space:
mode:
authorLoren J. Rittle <ljrittle@acm.org>2002-01-26 03:26:14 +0000
committerLoren J. Rittle <ljrittle@gcc.gnu.org>2002-01-26 03:26:14 +0000
commit63b3a44f03859984b064a41cf49732e97fd4adfe (patch)
treedde8f5e870c2080b8cb7675245ea1963794eab6a /libstdc++-v3/testsuite/thread
parent33c7f925c66c9e03e95c3ceaf76cb65bf4d218c1 (diff)
downloadgcc-63b3a44f03859984b064a41cf49732e97fd4adfe.zip
gcc-63b3a44f03859984b064a41cf49732e97fd4adfe.tar.gz
gcc-63b3a44f03859984b064a41cf49732e97fd4adfe.tar.bz2
pthread1.cc: Use one condition variable per predicate instead of tricky use of one condition...
* testsuite/thread/pthread1.cc: Use one condition variable per predicate instead of tricky use of one condition variable. From-SVN: r49239
Diffstat (limited to 'libstdc++-v3/testsuite/thread')
-rw-r--r--libstdc++-v3/testsuite/thread/pthread1.cc20
1 files changed, 10 insertions, 10 deletions
diff --git a/libstdc++-v3/testsuite/thread/pthread1.cc b/libstdc++-v3/testsuite/thread/pthread1.cc
index b8f5226..71afefc 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;