aboutsummaryrefslogtreecommitdiff
path: root/deps/uv/src/threadpool.c
diff options
context:
space:
mode:
authorcjihrig <cjihrig@gmail.com>2018-01-19 15:33:43 -0500
committercjihrig <cjihrig@gmail.com>2018-01-23 20:34:39 -0500
commita083786c7733b5828102661a04a86884c934950a (patch)
treea45536a61b50e7b5fa68a77d6f594de730c4a346 /deps/uv/src/threadpool.c
parent63f78f5ddc8ac50ea19839827682c51ff3363ac2 (diff)
downloadandroid-node-v8-a083786c7733b5828102661a04a86884c934950a.tar.gz
android-node-v8-a083786c7733b5828102661a04a86884c934950a.tar.bz2
android-node-v8-a083786c7733b5828102661a04a86884c934950a.zip
deps: upgrade libuv to 1.19.1
PR-URL: https://github.com/nodejs/node/pull/18260 Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'deps/uv/src/threadpool.c')
-rw-r--r--deps/uv/src/threadpool.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/deps/uv/src/threadpool.c b/deps/uv/src/threadpool.c
index 108934112c..413d1c204c 100644
--- a/deps/uv/src/threadpool.c
+++ b/deps/uv/src/threadpool.c
@@ -38,7 +38,6 @@ static uv_thread_t* threads;
static uv_thread_t default_threads[4];
static QUEUE exit_message;
static QUEUE wq;
-static volatile int initialized;
static void uv__cancelled(struct uv__work* w) {
@@ -53,7 +52,8 @@ static void worker(void* arg) {
struct uv__work* w;
QUEUE* q;
- (void) arg;
+ uv_sem_post((uv_sem_t*) arg);
+ arg = NULL;
for (;;) {
uv_mutex_lock(&mutex);
@@ -105,7 +105,7 @@ static void post(QUEUE* q) {
UV_DESTRUCTOR(static void cleanup(void)) {
unsigned int i;
- if (initialized == 0)
+ if (nthreads == 0)
return;
post(&exit_message);
@@ -122,7 +122,6 @@ UV_DESTRUCTOR(static void cleanup(void)) {
threads = NULL;
nthreads = 0;
- initialized = 0;
}
#endif
@@ -130,6 +129,7 @@ UV_DESTRUCTOR(static void cleanup(void)) {
static void init_threads(void) {
unsigned int i;
const char* val;
+ uv_sem_t sem;
nthreads = ARRAY_SIZE(default_threads);
val = getenv("UV_THREADPOOL_SIZE");
@@ -157,11 +157,17 @@ static void init_threads(void) {
QUEUE_INIT(&wq);
+ if (uv_sem_init(&sem, 0))
+ abort();
+
for (i = 0; i < nthreads; i++)
- if (uv_thread_create(threads + i, worker, NULL))
+ if (uv_thread_create(threads + i, worker, &sem))
abort();
- initialized = 1;
+ for (i = 0; i < nthreads; i++)
+ uv_sem_wait(&sem);
+
+ uv_sem_destroy(&sem);
}