summaryrefslogtreecommitdiff
path: root/thirdparty/libwebp/src/utils/thread_utils.c
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2019-10-27 13:54:05 +0100
committerGitHub <noreply@github.com>2019-10-27 13:54:05 +0100
commit61785bcc7d49cc2c6f1a351ed591dbf31748625b (patch)
treed47cd77a94c7b96d9c2f3800f6304f2ee5663d34 /thirdparty/libwebp/src/utils/thread_utils.c
parent2751cea0d4ed0bf99d870067dc8114701083d485 (diff)
parent074d421dca94ec4ddadfbfa62268bda219bab46c (diff)
Merge pull request #33109 from volzhs/libwebp-1.0.3
Update libwebp to 1.0.3
Diffstat (limited to 'thirdparty/libwebp/src/utils/thread_utils.c')
-rw-r--r--thirdparty/libwebp/src/utils/thread_utils.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/thirdparty/libwebp/src/utils/thread_utils.c b/thirdparty/libwebp/src/utils/thread_utils.c
index 2052b6b006..438296b45f 100644
--- a/thirdparty/libwebp/src/utils/thread_utils.c
+++ b/thirdparty/libwebp/src/utils/thread_utils.c
@@ -217,8 +217,12 @@ static THREADFN ThreadLoop(void* ptr) {
done = 1;
}
// signal to the main thread that we're done (for Sync())
- pthread_cond_signal(&impl->condition_);
+ // Note the associated mutex does not need to be held when signaling the
+ // condition. Unlocking the mutex first may improve performance in some
+ // implementations, avoiding the case where the waiting thread can't
+ // reacquire the mutex when woken.
pthread_mutex_unlock(&impl->mutex_);
+ pthread_cond_signal(&impl->condition_);
}
return THREAD_RETURN(NULL); // Thread is finished
}
@@ -240,7 +244,13 @@ static void ChangeState(WebPWorker* const worker, WebPWorkerStatus new_status) {
// assign new status and release the working thread if needed
if (new_status != OK) {
worker->status_ = new_status;
+ // Note the associated mutex does not need to be held when signaling the
+ // condition. Unlocking the mutex first may improve performance in some
+ // implementations, avoiding the case where the waiting thread can't
+ // reacquire the mutex when woken.
+ pthread_mutex_unlock(&impl->mutex_);
pthread_cond_signal(&impl->condition_);
+ return;
}
}
pthread_mutex_unlock(&impl->mutex_);