]> mj.ucw.cz Git - libucw.git/commitdiff
Use Threads.DefaultStackSize instead of various local stack sizes.
authorMartin Mares <mj@ucw.cz>
Sat, 9 Dec 2006 21:16:51 +0000 (22:16 +0100)
committerMartin Mares <mj@ucw.cz>
Sat, 9 Dec 2006 21:16:51 +0000 (22:16 +0100)
images/image-test.c
lib/asio.c
lib/workqueue.c
lib/workqueue.h

index b046672f9e1959aec7a3eb3df05a07d6ac0b54fd..0a22d47907abcf648d605316943e9a0e461e098d 100644 (file)
@@ -12,6 +12,7 @@
 #include "lib/lib.h"
 #include "lib/mempool.h"
 #include "lib/fastbuf.h"
+#include "lib/threads.h"
 #include "images/images.h"
 #include "images/color.h"
 
@@ -192,7 +193,7 @@ test_threads(void)
   pthread_t threads[TEST_THREADS_COUNT - 1];
   pthread_attr_t attr;
   if (pthread_attr_init(&attr) < 0 ||
-      pthread_attr_setstacksize(&attr, 1 << 20) < 0)
+      pthread_attr_setstacksize(&attr, default_thread_stack_size) < 0)
     ASSERT(0);
   for (uns i = 0; i < TEST_THREADS_COUNT - 1; i++)
     {
index 312dd6071c3f448822604998b39dcf36045bdffb..d495c2d7becc3529d1388e08ab537b4a609bdd5b 100644 (file)
@@ -28,7 +28,6 @@ asio_init_unlocked(void)
 
   DBG("ASIO: INIT");
   asio_wpool.num_threads = 1;
-  asio_wpool.stack_size = 65536;
   worker_pool_init(&asio_wpool);
 }
 
index a015e8788f9a7929b198434d85ef1ce2c8c184bf..3d87a74e191672c8e9a118e89a39e34ed948a648 100644 (file)
@@ -8,6 +8,7 @@
  */
 
 #include "lib/lib.h"
+#include "lib/threads.h"
 #include "lib/workqueue.h"
 
 static void *
@@ -48,7 +49,7 @@ worker_pool_init(struct worker_pool *p)
 
   pthread_attr_t attr;
   if (pthread_attr_init(&attr) < 0 ||
-      pthread_attr_setstacksize(&attr, p->stack_size) < 0)
+      pthread_attr_setstacksize(&attr, p->stack_size ? : default_thread_stack_size) < 0)
     ASSERT(0);
 
   for (uns i=0; i < p->num_threads; i++)
index 5f8b5fcdc91d7d80efec238fcc27a578c8b6f7cf..c16904abc2c694b0d53cb56c408363befc5bbd23 100644 (file)
@@ -47,7 +47,7 @@ struct raw_queue {                            // Generic queue with locking
 struct worker_pool {
   struct raw_queue requests;
   uns num_threads;
-  uns stack_size;
+  uns stack_size;                              // 0 for default
   struct worker_thread *(*new_thread)(void);   // default: xmalloc the struct
   void (*free_thread)(struct worker_thread *t);        // default: xfree
   void (*init_thread)(struct worker_thread *t);        // default: empty