MCPcopy Create free account
hub / github.com/EmmyLua/EmmyLuaDebugger / init_threads

Function init_threads

third-party/libuv-1.46.0/src/threadpool.c:193–241  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

191
192
193static void init_threads(void) {
194 uv_thread_options_t config;
195 unsigned int i;
196 const char* val;
197 uv_sem_t sem;
198
199 nthreads = ARRAY_SIZE(default_threads);
200 val = getenv("UV_THREADPOOL_SIZE");
201 if (val != NULL)
202 nthreads = atoi(val);
203 if (nthreads == 0)
204 nthreads = 1;
205 if (nthreads > MAX_THREADPOOL_SIZE)
206 nthreads = MAX_THREADPOOL_SIZE;
207
208 threads = default_threads;
209 if (nthreads > ARRAY_SIZE(default_threads)) {
210 threads = uv__malloc(nthreads * sizeof(threads[0]));
211 if (threads == NULL) {
212 nthreads = ARRAY_SIZE(default_threads);
213 threads = default_threads;
214 }
215 }
216
217 if (uv_cond_init(&cond))
218 abort();
219
220 if (uv_mutex_init(&mutex))
221 abort();
222
223 uv__queue_init(&wq);
224 uv__queue_init(&slow_io_pending_wq);
225 uv__queue_init(&run_slow_work_message);
226
227 if (uv_sem_init(&sem, 0))
228 abort();
229
230 config.flags = UV_THREAD_HAS_STACK_SIZE;
231 config.stack_size = 8u << 20; /* 8 MB */
232
233 for (i = 0; i < nthreads; i++)
234 if (uv_thread_create_ex(threads + i, &config, worker, &sem))
235 abort();
236
237 for (i = 0; i < nthreads; i++)
238 uv_sem_wait(&sem);
239
240 uv_sem_destroy(&sem);
241}
242
243
244#ifndef _WIN32

Callers 1

init_onceFunction · 0.85

Calls 8

uv__mallocFunction · 0.85
uv__queue_initFunction · 0.85
uv_cond_initFunction · 0.50
uv_mutex_initFunction · 0.50
uv_sem_initFunction · 0.50
uv_thread_create_exFunction · 0.50
uv_sem_waitFunction · 0.50
uv_sem_destroyFunction · 0.50

Tested by

no test coverage detected