summaryrefslogtreecommitdiff
path: root/vpx_util/vpx_thread.c
diff options
context:
space:
mode:
Diffstat (limited to 'vpx_util/vpx_thread.c')
-rw-r--r--vpx_util/vpx_thread.c36
1 files changed, 17 insertions, 19 deletions
diff --git a/vpx_util/vpx_thread.c b/vpx_util/vpx_thread.c
index 0132ce6f2..04c5fb6f2 100644
--- a/vpx_util/vpx_thread.c
+++ b/vpx_util/vpx_thread.c
@@ -13,7 +13,7 @@
// https://chromium.googlesource.com/webm/libwebp
#include <assert.h>
-#include <string.h> // for memset()
+#include <string.h> // for memset()
#include "./vpx_thread.h"
#include "vpx_mem/vpx_mem.h"
@@ -21,8 +21,8 @@
struct VPxWorkerImpl {
pthread_mutex_t mutex_;
- pthread_cond_t condition_;
- pthread_t thread_;
+ pthread_cond_t condition_;
+ pthread_t thread_;
};
//------------------------------------------------------------------------------
@@ -30,29 +30,28 @@ struct VPxWorkerImpl {
static void execute(VPxWorker *const worker); // Forward declaration.
static THREADFN thread_loop(void *ptr) {
- VPxWorker *const worker = (VPxWorker*)ptr;
+ VPxWorker *const worker = (VPxWorker *)ptr;
int done = 0;
while (!done) {
pthread_mutex_lock(&worker->impl_->mutex_);
- while (worker->status_ == OK) { // wait in idling mode
+ while (worker->status_ == OK) { // wait in idling mode
pthread_cond_wait(&worker->impl_->condition_, &worker->impl_->mutex_);
}
if (worker->status_ == WORK) {
execute(worker);
worker->status_ = OK;
- } else if (worker->status_ == NOT_OK) { // finish the worker
+ } else if (worker->status_ == NOT_OK) { // finish the worker
done = 1;
}
// signal to the main thread that we're done (for sync())
pthread_cond_signal(&worker->impl_->condition_);
pthread_mutex_unlock(&worker->impl_->mutex_);
}
- return THREAD_RETURN(NULL); // Thread is finished
+ return THREAD_RETURN(NULL); // Thread is finished
}
// main thread state control
-static void change_state(VPxWorker *const worker,
- VPxWorkerStatus new_status) {
+static void change_state(VPxWorker *const worker, VPxWorkerStatus new_status) {
// No-op when attempting to change state on a thread that didn't come up.
// Checking status_ without acquiring the lock first would result in a data
// race.
@@ -95,7 +94,7 @@ static int reset(VPxWorker *const worker) {
worker->had_error = 0;
if (worker->status_ < OK) {
#if CONFIG_MULTITHREAD
- worker->impl_ = (VPxWorkerImpl*)vpx_calloc(1, sizeof(*worker->impl_));
+ worker->impl_ = (VPxWorkerImpl *)vpx_calloc(1, sizeof(*worker->impl_));
if (worker->impl_ == NULL) {
return 0;
}
@@ -113,7 +112,7 @@ static int reset(VPxWorker *const worker) {
if (!ok) {
pthread_mutex_destroy(&worker->impl_->mutex_);
pthread_cond_destroy(&worker->impl_->condition_);
- Error:
+ Error:
vpx_free(worker->impl_);
worker->impl_ = NULL;
return 0;
@@ -161,15 +160,14 @@ static void end(VPxWorker *const worker) {
//------------------------------------------------------------------------------
-static VPxWorkerInterface g_worker_interface = {
- init, reset, sync, launch, execute, end
-};
+static VPxWorkerInterface g_worker_interface = { init, reset, sync,
+ launch, execute, end };
-int vpx_set_worker_interface(const VPxWorkerInterface* const winterface) {
- if (winterface == NULL ||
- winterface->init == NULL || winterface->reset == NULL ||
- winterface->sync == NULL || winterface->launch == NULL ||
- winterface->execute == NULL || winterface->end == NULL) {
+int vpx_set_worker_interface(const VPxWorkerInterface *const winterface) {
+ if (winterface == NULL || winterface->init == NULL ||
+ winterface->reset == NULL || winterface->sync == NULL ||
+ winterface->launch == NULL || winterface->execute == NULL ||
+ winterface->end == NULL) {
return 0;
}
g_worker_interface = *winterface;