summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbrunsch <brunsch@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1998-10-29 23:40:17 +0000
committerbrunsch <brunsch@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1998-10-29 23:40:17 +0000
commitae47ee5ea4d52a790a394787c7dee6752c50c095 (patch)
treef017921bcf706f2f27d15a79b2c4309bcd5aff30
parent58e9004b52081f3b337dc20bac7ab0f826dc4c24 (diff)
downloadATCD-ae47ee5ea4d52a790a394787c7dee6752c50c095.tar.gz
Removed the timed acquire stuff from the worker thread and the display at
the end of the test. Now it shouldn't output the confusing "100% of threads timed out" message on platforms without timed acquire.
-rw-r--r--tests/Semaphore_Test.cpp19
1 files changed, 15 insertions, 4 deletions
diff --git a/tests/Semaphore_Test.cpp b/tests/Semaphore_Test.cpp
index 15dd8f8f8a8..a424c1c5f5a 100644
--- a/tests/Semaphore_Test.cpp
+++ b/tests/Semaphore_Test.cpp
@@ -23,6 +23,8 @@
#include "ace/Thread_Manager.h"
#include "ace/Get_Opt.h"
+#define ACE_HAS_STHREADS
+
ACE_RCSID(tests, Semaphore_Test, "$Id$")
#if defined (__BORLANDC__) && __BORLANDC__ >= 0x0530
@@ -51,10 +53,10 @@ static size_t n_workers = 10;
// Amount to release the semaphore.
static size_t n_release_count = 3;
+#if !defined (ACE_HAS_STHREADS) && !defined (ACE_HAS_POSIX_SEM)
// Number of timeouts.
static size_t timeouts = 0;
-#if !defined (ACE_HAS_STHREADS) && !defined (ACE_HAS_POSIX_SEM)
// Number of times to call test_timeout ().
static size_t test_timeout_count = 3;
@@ -147,6 +149,9 @@ worker (void *)
iterations <= n_iterations;
iterations++)
{
+#if defined (ACE_HAS_STHREADS) && !defined (ACE_HAS_POSIX_SEM)
+ s.acquire ();
+#else
ACE_Time_Value wait (0,
iterations * 1000 * 100); // Wait 'iter' msec
ACE_Time_Value tv = ACE_OS::gettimeofday () + wait;
@@ -166,12 +171,14 @@ worker (void *)
diff.msec ()));
test_result = 1;
}
-
+#endif /* ACE_HAS_STHREADS && ACE_HAS_POSIX_SEM */
// Hold the lock for a while.
ACE_OS::sleep (ACE_Time_Value (0,
(ACE_OS::rand () % 1000) * 1000));
s.release ();
+#if !defined (ACE_HAS_STHREADS) && !defined (ACE_HAS_POSIX_SEM)
}
+#endif /* ACE_HAS_STHREADS && ACE_HAS_POSIX_SEM */
ACE_Thread::yield ();
}
@@ -191,12 +198,12 @@ int main (int argc, ASYS_TCHAR *argv[])
parse_args (argc, argv);
ACE_OS::srand (ACE_OS::time (0L));
-#if !defined (ACE_HAS_STHREADS) && !defined (ACE_HAS_POSIX_SEM)
+# if !defined (ACE_HAS_STHREADS) && !defined (ACE_HAS_POSIX_SEM)
//Test timed waits.
for (size_t i = 0; i < test_timeout_count; i++)
if (test_timeout () != 0)
test_result = 1;
-#endif /* ACE_HAS_STHREADS && ACE_HAS_POSIX_SEM */
+# endif /* ACE_HAS_STHREADS && ACE_HAS_POSIX_SEM */
// Release the semaphore a certain number of times.
s.release (n_release_count);
@@ -213,11 +220,15 @@ int main (int argc, ASYS_TCHAR *argv[])
ACE_Thread_Manager::instance ()->wait ();
+# if !defined (ACE_HAS_STHREADS) && !defined (ACE_HAS_POSIX_SEM)
size_t percent = (timeouts * 100) / (n_workers * n_iterations);
ACE_DEBUG ((LM_DEBUG,
ASYS_TEXT ("Worker threads timed out %d percent of the time\n"),
percent));
+# endif /* ACE_HAS_STHREADS && ACE_HAS_POSIX_SEM */
+
+ ACE_DEBUG ((LM_DEBUG, ASYS_TEXT ("Semaphore Test successful\n")));
#else
ACE_UNUSED_ARG (argc);
ACE_UNUSED_ARG (argv);