apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject svn commit: r562898 - /apr/apr-util/trunk/test/testpass.c
Date Sun, 05 Aug 2007 15:44:31 GMT
Author: davi
Date: Sun Aug  5 08:44:31 2007
New Revision: 562898

URL: http://svn.apache.org/viewvc?view=rev&rev=562898
Log:
Convert testpass to use a thread pool.

Modified:
    apr/apr-util/trunk/test/testpass.c

Modified: apr/apr-util/trunk/test/testpass.c
URL: http://svn.apache.org/viewvc/apr/apr-util/trunk/test/testpass.c?view=diff&rev=562898&r1=562897&r2=562898
==============================================================================
--- apr/apr-util/trunk/test/testpass.c (original)
+++ apr/apr-util/trunk/test/testpass.c Sun Aug  5 08:44:31 2007
@@ -21,7 +21,7 @@
 #include "apr_errno.h"
 #include "apr_strings.h"
 #include "apr_file_io.h"
-#include "apr_thread_proc.h"
+#include "apr_thread_pool.h"
 #include "apr_md5.h"
 #include "apr_sha1.h"
 
@@ -83,23 +83,24 @@
     return APR_SUCCESS;
 }
 
+#define NUM_THR 20
+
 /* test for threadsafe crypt() */
 static void test_threadsafe(abts_case *tc, void *data)
 {
-#define NUM_THR 20
-    apr_thread_t *my_threads[NUM_THR];
     int i;
     apr_status_t rv;
-    
-    for (i = 0; i < NUM_THR; i++) {
-        apr_assert_success(tc, "create test thread",
-                           apr_thread_create(&my_threads[i], NULL, 
-                                             testing_thread, tc, p));
-    }
+    apr_thread_pool_t *thrp;
+
+    rv = apr_thread_pool_create(&thrp, NUM_THR/2, NUM_THR, p);
+    ABTS_INT_EQUAL(tc, rv, APR_SUCCESS);
 
     for (i = 0; i < NUM_THR; i++) {
-        apr_thread_join(&rv, my_threads[i]);
+        rv = apr_thread_pool_push(thrp, testing_thread, tc, 0, NULL);
+        ABTS_INT_EQUAL(tc, rv, APR_SUCCESS);
     }
+
+    apr_thread_pool_destroy(thrp);
 }
 #endif
 



Mime
View raw message