43 static threadpool_t *last_thrpool_c; |
43 static threadpool_t *last_thrpool_c; |
44 |
44 |
45 static threadpool_t *default_io_pool; |
45 static threadpool_t *default_io_pool; |
46 static threadpool_t *last_io_pool; |
46 static threadpool_t *last_io_pool; |
47 |
47 |
48 int create_threadpool(sstr_t name, ThreadPoolConfig *cfg) { |
48 int create_threadpool(scstr_t name, ThreadPoolConfig *cfg) { |
49 if(thread_pool_map == NULL) { |
49 if(thread_pool_map == NULL) { |
50 thread_pool_map = ucx_map_new(16); |
50 thread_pool_map = ucx_map_new(16); |
51 } |
51 } |
52 |
52 |
53 threadpool_t *pool = ucx_map_sstr_get(thread_pool_map, name); |
53 threadpool_t *pool = ucx_map_sstr_get(thread_pool_map, name); |
75 |
75 |
76 return ret; |
76 return ret; |
77 } |
77 } |
78 } |
78 } |
79 |
79 |
80 int create_io_pool(sstr_t name, int numthreads) { |
80 int create_io_pool(scstr_t name, int numthreads) { |
81 if(io_pool_map == NULL) { |
81 if(io_pool_map == NULL) { |
82 io_pool_map = ucx_map_new(4); |
82 io_pool_map = ucx_map_new(4); |
83 } |
83 } |
84 threadpool_t *pool = ucx_map_sstr_get(io_pool_map, name); |
84 threadpool_t *pool = ucx_map_sstr_get(io_pool_map, name); |
85 if(pool) { |
85 if(pool) { |
108 ThreadPoolConfig cfg; |
108 ThreadPoolConfig cfg; |
109 cfg.min_threads = 4; |
109 cfg.min_threads = 4; |
110 cfg.max_threads = 8; |
110 cfg.max_threads = 8; |
111 cfg.queue_size = 64; |
111 cfg.queue_size = 64; |
112 cfg.stack_size = 262144; |
112 cfg.stack_size = 262144; |
113 if(create_threadpool(sstr("default"), &cfg)) { |
113 if(create_threadpool(SC("default"), &cfg)) { |
114 return 1; |
114 return 1; |
115 } |
115 } |
116 } |
116 } |
117 |
117 |
118 if(num_iopools == 0) { |
118 if(num_iopools == 0) { |
119 if(create_io_pool(sstr("default"), 8)) { |
119 if(create_io_pool(SC("default"), 8)) { |
120 return 1; |
120 return 1; |
121 } |
121 } |
122 } |
122 } |
123 |
123 |
124 return 0; |
124 return 0; |