stdcxx-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vi...@apache.org
Subject svn commit: r655960 - in /stdcxx/branches/4.2.x/tests: include/ localization/ src/
Date Tue, 13 May 2008 18:21:50 GMT
Author: vitek
Date: Tue May 13 11:21:50 2008
New Revision: 655960

URL: http://svn.apache.org/viewvc?rev=655960&view=rev
Log:
2008-05-07  Travis Vitek  <vitek@roguewave.com>

	STDCXX-536
	* tests/include/rw_thread.h (rw_thread_pool): Add timeout
	parameter with default value.
	(rw_thread_pool_timeout_expired): New function declaration.
	* tests/src/thread.cpp: (_rw_timeout_handler): New function
	to respond to alarm signals and set timeout flag.
	(rw_thread_pool_timeout_expired): New function to query
	timeout status.
	(rw_thread_pool): Set alarm based on timeout value provided.
	* tests/localization/22.locale.codecvt.mt.cpp: Add timeout
	option with default value. Pass timeout to rw_thread_pool().
	Poll rw_thread_pool_time_expired() in thread function and
	respond. Removed rw_ prefix used by test driver symbols.
	* tests/localization/22.locale.cons.mt.cpp: Ditto.
	* tests/localization/22.locale.ctype.mt.cpp: Ditto.
	* tests/localization/22.locale.globals.mt.cpp: Ditto.
	* tests/localization/22.locale.messages.mt.cpp: Ditto.
	* tests/localization/22.locale.money.get.mt.cpp: Ditto.
	* tests/localization/22.locale.money.put.mt.cpp: Ditto.
	* tests/localization/22.locale.moneypunct.mt.cpp: Ditto.
	* tests/localization/22.locale.num.get.mt.cpp: Ditto.
	* tests/localization/22.locale.num.put.mt.cpp: Ditto.
	* tests/localization/22.locale.numpunct.mt.cpp: Ditto.
	* tests/localization/22.locale.statics.mt.cpp: Ditto.
	* tests/localization/22.locale.time.get.mt.cpp: Ditto.
	* tests/localization/22.locale.time.put.mt.cpp: Ditto.

Modified:
    stdcxx/branches/4.2.x/tests/include/rw_thread.h
    stdcxx/branches/4.2.x/tests/localization/22.locale.codecvt.mt.cpp
    stdcxx/branches/4.2.x/tests/localization/22.locale.cons.mt.cpp
    stdcxx/branches/4.2.x/tests/localization/22.locale.ctype.mt.cpp
    stdcxx/branches/4.2.x/tests/localization/22.locale.globals.mt.cpp
    stdcxx/branches/4.2.x/tests/localization/22.locale.messages.mt.cpp
    stdcxx/branches/4.2.x/tests/localization/22.locale.money.get.mt.cpp
    stdcxx/branches/4.2.x/tests/localization/22.locale.money.put.mt.cpp
    stdcxx/branches/4.2.x/tests/localization/22.locale.moneypunct.mt.cpp
    stdcxx/branches/4.2.x/tests/localization/22.locale.num.get.mt.cpp
    stdcxx/branches/4.2.x/tests/localization/22.locale.num.put.mt.cpp
    stdcxx/branches/4.2.x/tests/localization/22.locale.numpunct.mt.cpp
    stdcxx/branches/4.2.x/tests/localization/22.locale.statics.mt.cpp
    stdcxx/branches/4.2.x/tests/localization/22.locale.time.get.mt.cpp
    stdcxx/branches/4.2.x/tests/localization/22.locale.time.put.mt.cpp
    stdcxx/branches/4.2.x/tests/src/thread.cpp

Modified: stdcxx/branches/4.2.x/tests/include/rw_thread.h
URL: http://svn.apache.org/viewvc/stdcxx/branches/4.2.x/tests/include/rw_thread.h?rev=655960&r1=655959&r2=655960&view=diff
==============================================================================
--- stdcxx/branches/4.2.x/tests/include/rw_thread.h (original)
+++ stdcxx/branches/4.2.x/tests/include/rw_thread.h Tue May 13 11:21:50 2008
@@ -62,6 +62,13 @@
 // array with their id's; if (tidarray == 0), waits for all
 // threads to join and fills the aragarray with the result
 // returned from each thread
+// if (timeout != 0), then a timer will be started, and the function
+// rw_thread_pool_timeout_expired() will return true after that number
+// of seconds has passed. there is only one timer, so use timeouts
+// with caution. if you provide tidarray, you should join threads
+// before starting another pool, otherwise threads from the first
+// pool may not exit until the threads from a later second pool are
+// signalled to stop.
 // if (nthreads == SIZE_MAX), sets nthreads to the positive result
 // of rw_get_processors() plus 1, or to 2 otherwise
 // returns 0 on success, or a non-zero value indicating the thread
@@ -71,7 +78,15 @@
                 _RWSTD_SIZE_T     /* nthreads */,
                 rw_thread_attr_t* /* attr */,
                 void* (*)(void*)  /* thr_proc */,
-                void**            /* argarray */);
+                void**            /* argarray */,
+                _RWSTD_SIZE_T     /* timeout  */ = 0);
+
+// returns non-zero if the thread timeout flag has been set. should
+// be polled periodically by threads created by rw_thread_pool() so
+// that they know that the soft timeout has expired
+// see notes above for details
+_TEST_EXPORT int
+rw_thread_pool_timeout_expired ();
 
 // returns the number of logical processors/cores on the system,
 // or -1 on error
@@ -79,6 +94,7 @@
 rw_get_cpus ();
 
 
+
 }   // extern "C"
 
 #endif   // RW_RWTHREAD_H_INCLUDED

Modified: stdcxx/branches/4.2.x/tests/localization/22.locale.codecvt.mt.cpp
URL: http://svn.apache.org/viewvc/stdcxx/branches/4.2.x/tests/localization/22.locale.codecvt.mt.cpp?rev=655960&r1=655959&r2=655960&view=diff
==============================================================================
--- stdcxx/branches/4.2.x/tests/localization/22.locale.codecvt.mt.cpp (original)
+++ stdcxx/branches/4.2.x/tests/localization/22.locale.codecvt.mt.cpp Tue May 13 11:21:50
2008
@@ -58,6 +58,9 @@
 // of creating their own?
 int opt_shared_locale;
 
+// default timeout used by each threaded section of this test
+int opt_timeout = 60;
+
 /**************************************************************************/
 
 // array of locale names to use for testing
@@ -316,6 +319,9 @@
 
     for (int i = 0; i != opt_nloops; ++i) {
 
+        if (rw_thread_pool_timeout_expired ())
+            break;
+
         const int inx = i % nlocales;
         const MyCodecvtData& data = my_codecvt_data [inx];
 
@@ -550,11 +556,13 @@
     return rw_test (argc, argv, __FILE__,
                     "lib.locale.codecvt",
                     "thread safety", run_test,
+                    "|-soft-timeout#0 "  // must be non-negative
                     "|-nloops#0 "        // must be non-negative
                     "|-nthreads#0-* "    // must be in [0, MAX_THREADS]
                     "|-nlocales#0 "      // arg must be non-negative
                     "|-locales= "        // must be provided
                     "|-shared-locale# ",
+                    &opt_timeout,
                     &opt_nloops,
                     int (MAX_THREADS),
                     &opt_nthreads,

Modified: stdcxx/branches/4.2.x/tests/localization/22.locale.cons.mt.cpp
URL: http://svn.apache.org/viewvc/stdcxx/branches/4.2.x/tests/localization/22.locale.cons.mt.cpp?rev=655960&r1=655959&r2=655960&view=diff
==============================================================================
--- stdcxx/branches/4.2.x/tests/localization/22.locale.cons.mt.cpp (original)
+++ stdcxx/branches/4.2.x/tests/localization/22.locale.cons.mt.cpp Tue May 13 11:21:50 2008
@@ -50,6 +50,9 @@
 // command line option
 int opt_combine;
 
+// default timeout used by each threaded section of this test
+int opt_timeout = 60;
+
 /**************************************************************************/
 
 // array of locale names to use for testing
@@ -85,6 +88,9 @@
 
     for (int i = 0; i != opt_nloops; ++i) {
 
+        if (rw_thread_pool_timeout_expired ())
+            break;
+
         // compute an index into the array of locales
         const std::size_t linx = i % nlocales;
 
@@ -210,10 +216,12 @@
                     "lib.locale.cons",
                     "thread safety", run_test,
                     "|-combine~ "
+                    "|-soft-timeout#0 "  // must be non-negative
                     "|-nloops#0 "        // must be non-negative
                     "|-nthreads#0-* "    // must be in [0, MAX_THREADS]
                     "|-locales=",        // must be provided
                     &opt_combine,
+                    &opt_timeout,
                     &opt_nloops,
                     int (MAX_THREADS),
                     &opt_nthreads,

Modified: stdcxx/branches/4.2.x/tests/localization/22.locale.ctype.mt.cpp
URL: http://svn.apache.org/viewvc/stdcxx/branches/4.2.x/tests/localization/22.locale.ctype.mt.cpp?rev=655960&r1=655959&r2=655960&view=diff
==============================================================================
--- stdcxx/branches/4.2.x/tests/localization/22.locale.ctype.mt.cpp (original)
+++ stdcxx/branches/4.2.x/tests/localization/22.locale.ctype.mt.cpp Tue May 13 11:21:50 2008
@@ -66,6 +66,9 @@
 // of creating their own?
 int opt_shared_locale;
 
+// default timeout used by each threaded section of this test
+int opt_timeout = 60;
+
 /**************************************************************************/
 
 // array of locale names to use for testing
@@ -118,6 +121,9 @@
 
     for (int i = 0; i != opt_nloops; ++i) {
 
+        if (rw_thread_pool_timeout_expired ())
+            break;
+
         const std::size_t inx = std::size_t (i) % nlocales;
 
         // save the name of the locale
@@ -321,11 +327,13 @@
     return rw_test (argc, argv, __FILE__,
                     "lib.locale.ctype",
                     "thread safety", run_test,
+                    "|-soft-timeout#0 "  // must be non-negative
                     "|-nloops#0 "        // arg must be non-negative
                     "|-nthreads#0-* "    // arg must be in [0, MAX_THREADS]
                     "|-nlocales#0 "      // arg must be non-negative
                     "|-locales= "        // arg must be provided
                     "|-shared-locale# ",
+                    &opt_timeout,
                     &opt_nloops,
                     int (MAX_THREADS),
                     &opt_nthreads,

Modified: stdcxx/branches/4.2.x/tests/localization/22.locale.globals.mt.cpp
URL: http://svn.apache.org/viewvc/stdcxx/branches/4.2.x/tests/localization/22.locale.globals.mt.cpp?rev=655960&r1=655959&r2=655960&view=diff
==============================================================================
--- stdcxx/branches/4.2.x/tests/localization/22.locale.globals.mt.cpp (original)
+++ stdcxx/branches/4.2.x/tests/localization/22.locale.globals.mt.cpp Tue May 13 11:21:50
2008
@@ -73,6 +73,9 @@
 // disable exceptions?
 int opt_no_exceptions;
 
+// default timeout used by each threaded section of this test
+int opt_timeout = 60;
+
 /**************************************************************************/
 
 // array of locale names to use for testing
@@ -149,6 +152,9 @@
 
     for (int i = 0; i != opt_nloops; ++i) {
 
+        if (rw_thread_pool_timeout_expired ())
+            break;
+
         // save the name of the locale
         const char* const locale_name = locales [i % nlocales];
 
@@ -395,6 +401,10 @@
     const std::locale classic (std::locale::classic ());
 
     for (int i = 0; i != opt_nloops; ++i) {
+
+        if (rw_thread_pool_timeout_expired ())
+            break;
+
         try {
             use_facet_loop (classic, i);
         }
@@ -586,6 +596,7 @@
                     "thread safety", run_test,
                     "|-has_facet~ "
                     "|-use_facet~ "
+                    "|-soft-timeout#0 "  // must be non-negative
                     "|-nloops#0 "        // arg must be non-negative
                     "|-nthreads#0-* "    // arg must be in [0, MAX_THREADS]
                     "|-locales= "        // argument must be provided
@@ -605,6 +616,7 @@
                     "|-time_put~ ",
                     &opt_has_facet,
                     &opt_use_facet,
+                    &opt_timeout,
                     &opt_nloops,
                     int (MAX_THREADS),
                     &opt_nthreads,

Modified: stdcxx/branches/4.2.x/tests/localization/22.locale.messages.mt.cpp
URL: http://svn.apache.org/viewvc/stdcxx/branches/4.2.x/tests/localization/22.locale.messages.mt.cpp?rev=655960&r1=655959&r2=655960&view=diff
==============================================================================
--- stdcxx/branches/4.2.x/tests/localization/22.locale.messages.mt.cpp (original)
+++ stdcxx/branches/4.2.x/tests/localization/22.locale.messages.mt.cpp Tue May 13 11:21:50
2008
@@ -71,6 +71,9 @@
 // of creating their own?
 int opt_shared_locale;
 
+// default timeout used by each threaded section of this test
+int opt_timeout = 60;
+
 /**************************************************************************/
 
 // array of locale names to use for testing
@@ -474,9 +477,11 @@
     return rw_test (argc, argv, __FILE__,
                     "lib.locale.messages",
                     "thread safety", run_test,
+                    "|-soft-timeout#0 "  // must be non-negative
                     "|-nloops#0 "        // must be non-negative
                     "|-ncatalogs#0-* "   // must be non-negative
                     "|-nthreads#0-* ",    // must be in [0, MAX_THREADS]
+                    &opt_timeout,
                     &opt_nloops,
                     int (MAX_CATALOGS),
                     &opt_ncatalogs,

Modified: stdcxx/branches/4.2.x/tests/localization/22.locale.money.get.mt.cpp
URL: http://svn.apache.org/viewvc/stdcxx/branches/4.2.x/tests/localization/22.locale.money.get.mt.cpp?rev=655960&r1=655959&r2=655960&view=diff
==============================================================================
--- stdcxx/branches/4.2.x/tests/localization/22.locale.money.get.mt.cpp (original)
+++ stdcxx/branches/4.2.x/tests/localization/22.locale.money.get.mt.cpp Tue May 13 11:21:50
2008
@@ -67,6 +67,9 @@
 // of creating their own?
 int opt_shared_locale;
 
+// default timeout used by each threaded section of this test
+int opt_timeout = 60;
+
 /**************************************************************************/
 
 // array of locale names to use for testing
@@ -176,6 +179,9 @@
 
     for (int i = 0; i != opt_nloops; ++i) {
 
+        if (rw_thread_pool_timeout_expired ())
+            break;
+
         // save the name of the locale
         const MyMoneyData& data = my_money_data [i % nlocales];
 
@@ -464,11 +470,13 @@
     return rw_test (argc, argv, __FILE__,
                     "lib.locale.money.get",
                     "thread safety", run_test,
+                    "|-soft-timeout#0 "  // must be non-negative
                     "|-nloops#0 "        // must be non-negative
                     "|-nthreads#0-* "    // must be in [0, MAX_THREADS]
                     "|-nlocales#0 "      // arg must be non-negative
                     "|-locales= "        // must be provided
                     "|-shared-locale# ",
+                    &opt_timeout,
                     &opt_nloops,
                     int (MAX_THREADS),
                     &opt_nthreads,

Modified: stdcxx/branches/4.2.x/tests/localization/22.locale.money.put.mt.cpp
URL: http://svn.apache.org/viewvc/stdcxx/branches/4.2.x/tests/localization/22.locale.money.put.mt.cpp?rev=655960&r1=655959&r2=655960&view=diff
==============================================================================
--- stdcxx/branches/4.2.x/tests/localization/22.locale.money.put.mt.cpp (original)
+++ stdcxx/branches/4.2.x/tests/localization/22.locale.money.put.mt.cpp Tue May 13 11:21:50
2008
@@ -67,6 +67,9 @@
 // of creating their own?
 int opt_shared_locale;
 
+// default timeout used by each threaded section of this test
+int opt_timeout = 60;
+
 /**************************************************************************/
 
 // array of locale names to use for testing
@@ -184,6 +187,9 @@
 
     for (int i = 0; i != opt_nloops; ++i) {
 
+        if (rw_thread_pool_timeout_expired ())
+            break;
+
         // save the name of the locale
         const MyMoneyData& data = my_money_data [i % nlocales];
 
@@ -470,11 +476,13 @@
     return rw_test (argc, argv, __FILE__,
                     "lib.locale.money.put",
                     "thread safety", run_test,
+                    "|-soft-timeout#0 "  // must be non-negative
                     "|-nloops#0 "        // must be non-negative
                     "|-nthreads#0-* "    // must be in [0, MAX_THREADS]
                     "|-nlocales#0 "      // arg must be non-negative
                     "|-locales= "        // must be provided
                     "|-shared-locale# ",
+                    &opt_timeout,
                     &opt_nloops,
                     int (MAX_THREADS),
                     &opt_nthreads,

Modified: stdcxx/branches/4.2.x/tests/localization/22.locale.moneypunct.mt.cpp
URL: http://svn.apache.org/viewvc/stdcxx/branches/4.2.x/tests/localization/22.locale.moneypunct.mt.cpp?rev=655960&r1=655959&r2=655960&view=diff
==============================================================================
--- stdcxx/branches/4.2.x/tests/localization/22.locale.moneypunct.mt.cpp (original)
+++ stdcxx/branches/4.2.x/tests/localization/22.locale.moneypunct.mt.cpp Tue May 13 11:21:50
2008
@@ -52,6 +52,9 @@
 // DFLT_LOOPS unless explicitly specified on the command line)
 int opt_nloops = -1;
 
+// default timeout used by each threaded section of this test
+int opt_timeout = 60;
+
 /**************************************************************************/
 
 // number of locales to test
@@ -242,6 +245,9 @@
 {
     for (int i = 0; i != opt_nloops; ++i) {
 
+        if (rw_thread_pool_timeout_expired ())
+            break;
+
         thread_loop_body (std::size_t (i));
     }
 
@@ -475,9 +481,11 @@
     return rw_test (argc, argv, __FILE__,
                     "lib.locale.moneypunct",
                     "thread safety", run_test,
+                    "|-soft-timeout#0 "  // must be non-negative
                     "|-nloops#0 "       // must be non-negative
                     "|-nthreads#0-* "   // must be in [0, MAX_THREADS]
                     "|-locales=",       // must be provided
+                    &opt_timeout,
                     &opt_nloops,
                     int (MAX_THREADS),
                     &opt_nthreads,

Modified: stdcxx/branches/4.2.x/tests/localization/22.locale.num.get.mt.cpp
URL: http://svn.apache.org/viewvc/stdcxx/branches/4.2.x/tests/localization/22.locale.num.get.mt.cpp?rev=655960&r1=655959&r2=655960&view=diff
==============================================================================
--- stdcxx/branches/4.2.x/tests/localization/22.locale.num.get.mt.cpp (original)
+++ stdcxx/branches/4.2.x/tests/localization/22.locale.num.get.mt.cpp Tue May 13 11:21:50
2008
@@ -64,6 +64,9 @@
 // of creating their own?
 int opt_shared_locale;
 
+// default timeout used by each threaded section of this test
+int opt_timeout = 60;
+
 /**************************************************************************/
 
 // array of locale names to use for testing
@@ -342,6 +345,9 @@
 
     for (int i = 0; i != opt_nloops; ++i) {
 
+        if (rw_thread_pool_timeout_expired ())
+            break;
+
         // fill in the value and results for this locale
         const MyNumData& data = my_num_data [i % nlocales];
 
@@ -564,11 +570,13 @@
     return rw_test (argc, argv, __FILE__,
                     "lib.locale.num.get",
                     "thread safety", run_test,
+                    "|-soft-timeout#0 "  // must be non-negative
                     "|-nloops#0 "       // must be non-negative
                     "|-nthreads#0-* "   // must be in [0, MAX_THREADS]
                     "|-nlocales#0 "     // arg must be non-negative
                     "|-locales= "       // must be provided
                     "|-shared-locale# ",
+                    &opt_timeout,
                     &opt_nloops,
                     int (MAX_THREADS),
                     &opt_nthreads,

Modified: stdcxx/branches/4.2.x/tests/localization/22.locale.num.put.mt.cpp
URL: http://svn.apache.org/viewvc/stdcxx/branches/4.2.x/tests/localization/22.locale.num.put.mt.cpp?rev=655960&r1=655959&r2=655960&view=diff
==============================================================================
--- stdcxx/branches/4.2.x/tests/localization/22.locale.num.put.mt.cpp (original)
+++ stdcxx/branches/4.2.x/tests/localization/22.locale.num.put.mt.cpp Tue May 13 11:21:50
2008
@@ -64,6 +64,9 @@
 // of creating their own?
 int opt_shared_locale;
 
+// default timeout used by each threaded section of this test
+int opt_timeout = 60;
+
 /**************************************************************************/
 
 // array of locale names to use for testing
@@ -238,6 +241,9 @@
 
     for (int i = 0; i != opt_nloops; ++i) {
 
+        if (rw_thread_pool_timeout_expired ())
+            break;
+
         // fill in the value and results for this locale
         const MyNumData& data = my_num_data [i % nlocales];
 
@@ -454,11 +460,13 @@
     return rw_test (argc, argv, __FILE__,
                     "lib.locale.num.put",
                     "thread safety", run_test,
+                    "|-soft-timeout#0 "  // must be non-negative
                     "|-nloops#0 "       // must be non-negative
                     "|-nthreads#0-* "   // must be in [0, MAX_THREADS]
                     "|-nlocales#0 "     // arg must be non-negative
                     "|-locales= "       // must be provided
                     "|-shared-locale# ",
+                    &opt_timeout,
                     &opt_nloops,
                     int (MAX_THREADS),
                     &opt_nthreads,

Modified: stdcxx/branches/4.2.x/tests/localization/22.locale.numpunct.mt.cpp
URL: http://svn.apache.org/viewvc/stdcxx/branches/4.2.x/tests/localization/22.locale.numpunct.mt.cpp?rev=655960&r1=655959&r2=655960&view=diff
==============================================================================
--- stdcxx/branches/4.2.x/tests/localization/22.locale.numpunct.mt.cpp (original)
+++ stdcxx/branches/4.2.x/tests/localization/22.locale.numpunct.mt.cpp Tue May 13 11:21:50
2008
@@ -66,6 +66,9 @@
 // of creating their own?
 int opt_shared_locale;
 
+// default timeout used by each threaded section of this test
+int opt_timeout = 60;
+
 /**************************************************************************/
 
 // array of locale names to use for testing
@@ -113,6 +116,9 @@
 {
     for (int i = 0; i != opt_nloops; ++i) {
 
+        if (rw_thread_pool_timeout_expired ())
+            break;
+
         const std::size_t inx = std::size_t (i) % nlocales;
 
         const NumPunctData& data = punct_data[inx];
@@ -321,11 +327,13 @@
     return rw_test (argc, argv, __FILE__,
                     "lib.locale.numpunct",
                     "thread safety", run_test,
+                    "|-soft-timeout#0 "  // must be non-negative
                     "|-nloops#0 "       // must be non-negative
                     "|-nthreads#0-* "   // must be in [0, MAX_THREADS]
                     "|-nlocales#0 "     // arg must be non-negative
                     "|-locales= "       // must be provided
                     "|-shared-locale# ",
+                    &opt_timeout,
                     &opt_nloops,
                     int (MAX_THREADS),
                     &opt_nthreads,

Modified: stdcxx/branches/4.2.x/tests/localization/22.locale.statics.mt.cpp
URL: http://svn.apache.org/viewvc/stdcxx/branches/4.2.x/tests/localization/22.locale.statics.mt.cpp?rev=655960&r1=655959&r2=655960&view=diff
==============================================================================
--- stdcxx/branches/4.2.x/tests/localization/22.locale.statics.mt.cpp (original)
+++ stdcxx/branches/4.2.x/tests/localization/22.locale.statics.mt.cpp Tue May 13 11:21:50
2008
@@ -50,6 +50,9 @@
 int opt_classic;
 int opt_global;
 
+// default timeout used by each threaded section of this test
+int opt_timeout = 60;
+
 /**************************************************************************/
 
 // array of locale objects to use for testing
@@ -92,6 +95,9 @@
 {
     for (std::size_t i = 0; i != opt_nloops; ++i) {
 
+        if (rw_thread_pool_timeout_expired ())
+            break;
+
         const std::size_t inx = i % nlocales;
 
         const std::locale last (std::locale::global (locales [inx]));
@@ -187,11 +193,13 @@
                     run_test,
                     "|-classic~ "
                     "|-global~ "
+                    "|-soft-timeout#0 "  // must be non-negative
                     "|-nloops#0 "        // arg must be non-negative
                     "|-nthreads#0-* "    // arg must be in [0, MAX_THREADS]
                     "|-locales= ",       // argument must be provided
                     &opt_classic,
                     &opt_global,
+                    &opt_timeout,
                     &opt_nloops,
                     int (MAX_THREADS),
                     &opt_nthreads,

Modified: stdcxx/branches/4.2.x/tests/localization/22.locale.time.get.mt.cpp
URL: http://svn.apache.org/viewvc/stdcxx/branches/4.2.x/tests/localization/22.locale.time.get.mt.cpp?rev=655960&r1=655959&r2=655960&view=diff
==============================================================================
--- stdcxx/branches/4.2.x/tests/localization/22.locale.time.get.mt.cpp (original)
+++ stdcxx/branches/4.2.x/tests/localization/22.locale.time.get.mt.cpp Tue May 13 11:21:50
2008
@@ -55,6 +55,9 @@
 // of creating their own?
 int opt_shared_locale;
 
+// default timeout used by each threaded section of this test
+int opt_timeout = 60;
+
 /**************************************************************************/
 
 // array of locale names to use for testing
@@ -164,6 +167,9 @@
     std::tm local;
     for (int i = 0; i != opt_nloops; ++i) {
 
+        if (rw_thread_pool_timeout_expired ())
+            break;
+
         // save the name of the locale
         const MyTimeData& data = my_time_data [i % nlocales];
 
@@ -513,11 +519,13 @@
     return rw_test (argc, argv, __FILE__,
                     "lib.locale.time.get",
                     "thread safety", run_test,
+                    "|-soft-timeout#0 "  // must be non-negative
                     "|-nloops#0 "       // must be non-negative
                     "|-nthreads#0-* "   // must be in [0, MAX_THREADS]
                     "|-nlocales#0 "     // arg must be non-negative
                     "|-locales= "       // must be provided
                     "|-shared-locale# ",
+                    &opt_timeout,
                     &opt_nloops,
                     int (MAX_THREADS),
                     &opt_nthreads,

Modified: stdcxx/branches/4.2.x/tests/localization/22.locale.time.put.mt.cpp
URL: http://svn.apache.org/viewvc/stdcxx/branches/4.2.x/tests/localization/22.locale.time.put.mt.cpp?rev=655960&r1=655959&r2=655960&view=diff
==============================================================================
--- stdcxx/branches/4.2.x/tests/localization/22.locale.time.put.mt.cpp (original)
+++ stdcxx/branches/4.2.x/tests/localization/22.locale.time.put.mt.cpp Tue May 13 11:21:50
2008
@@ -67,6 +67,9 @@
 // of creating their own?
 int opt_shared_locale;
 
+// default timeout used by each threaded section of this test
+int opt_timeout = 60;
+
 /**************************************************************************/
 
 // array of locale names to use for testing
@@ -157,6 +160,9 @@
 
     for (int i = 0; i != opt_nloops; ++i) {
 
+        if (rw_thread_pool_timeout_expired ())
+            break;
+
         // save the name of the locale
         const MyTimeData& data = my_time_data [i % nlocales];
 
@@ -391,11 +397,13 @@
     return rw_test (argc, argv, __FILE__,
                     "lib.locale.time.put",
                     "thread safety", run_test,
+                    "|-soft-timeout#0 "  // must be non-negative
                     "|-nloops#0 "       // must be non-negative
                     "|-nthreads#0-* "   // must be in [0, MAX_THREADS]
                     "|-nlocales#0 "     // arg must be non-negative
                     "|-locales= "       // must be provided
                     "|-shared-locale# ",
+                    &opt_timeout,
                     &opt_nloops,
                     int (MAX_THREADS),
                     &opt_nthreads,

Modified: stdcxx/branches/4.2.x/tests/src/thread.cpp
URL: http://svn.apache.org/viewvc/stdcxx/branches/4.2.x/tests/src/thread.cpp?rev=655960&r1=655959&r2=655960&view=diff
==============================================================================
--- stdcxx/branches/4.2.x/tests/src/thread.cpp (original)
+++ stdcxx/branches/4.2.x/tests/src/thread.cpp Tue May 13 11:21:50 2008
@@ -30,6 +30,7 @@
 #define _RWSTD_TEST_SRC
 
 #include <rw_thread.h>
+#include <rw_alarm.h>   // for rw_alarm()
 #include <stddef.h>     // for size_t
 #include <string.h>     // for memset()
 
@@ -52,6 +53,29 @@
 
 static long maxthreads;
 
+/************************************************************************/
+
+static volatile int
+_rw_timeout_expired = 0;
+
+/************************************************************************/
+
+_TEST_EXPORT int
+rw_thread_pool_timeout_expired ()
+{
+    return _rw_timeout_expired != 0;
+}
+
+/************************************************************************/
+
+static void
+_rw_timeout_handler (int)
+{
+    _rw_timeout_expired = 1;
+}
+
+/************************************************************************/
+
 
 #if defined (_RWSTD_POSIX_THREADS)
 #  include <pthread.h>
@@ -479,8 +503,15 @@
                 size_t              nthrs,
                 rw_thread_attr_t*,
                 void*             (*thr_proc)(void*),
-                void*              *thr_arg)
+                void*              *thr_arg,
+                size_t              timeout)
 {
+    // apply timeout if one was specified
+    if (0 != timeout) {
+        _rw_timeout_expired = 0;
+        rw_alarm (timeout, _rw_timeout_handler);
+    }
+
     // small buffer for thread ids when invoked with (thr_id == 0)
     rw_thread_t id_buf [16];
 



Mime
View raw message