From 3d135324da38085026a0bde4ad4f4aa9f216e243 Mon Sep 17 00:00:00 2001 From: Ari Koivula Date: Wed, 4 Mar 2015 16:30:20 +0200 Subject: [PATCH] Rename struct threadqueue_queue to threadqueue_queue_t. --- src/encoder.c | 2 +- src/encoder.h | 2 +- src/threadqueue.c | 22 +++++++++++----------- src/threadqueue.h | 16 ++++++++-------- 4 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/encoder.c b/src/encoder.c index 070b2917..77c29d4d 100644 --- a/src/encoder.c +++ b/src/encoder.c @@ -50,7 +50,7 @@ int encoder_control_init(encoder_control_t * const encoder, const config_t * con return 0; } - encoder->threadqueue = MALLOC(threadqueue_queue, 1); + encoder->threadqueue = MALLOC(threadqueue_queue_t, 1); encoder->owf = cfg->owf; diff --git a/src/encoder.h b/src/encoder.h index 2bbec936..03de071f 100644 --- a/src/encoder.h +++ b/src/encoder.h @@ -133,7 +133,7 @@ typedef struct encoder_control_t int slice_count; const int* slice_addresses_in_ts; - threadqueue_queue *threadqueue; + threadqueue_queue_t *threadqueue; struct { uint8_t min; diff --git a/src/threadqueue.c b/src/threadqueue.c index 9ebbebd8..25de443c 100644 --- a/src/threadqueue.c +++ b/src/threadqueue.c @@ -33,7 +33,7 @@ #include "threads.h" typedef struct { - threadqueue_queue * threadqueue; + threadqueue_queue_t * threadqueue; int worker_id; } threadqueue_worker_spec; @@ -78,7 +78,7 @@ const struct timespec time_to_wait = {1, 0}; static void* threadqueue_worker(void* threadqueue_worker_spec_opaque) { threadqueue_worker_spec * const threadqueue_worker_spec = threadqueue_worker_spec_opaque; - threadqueue_queue * const threadqueue = threadqueue_worker_spec->threadqueue; + threadqueue_queue_t * const threadqueue = threadqueue_worker_spec->threadqueue; threadqueue_job_t * next_job = NULL; #ifdef _DEBUG @@ -233,7 +233,7 @@ static void* threadqueue_worker(void* threadqueue_worker_spec_opaque) { return NULL; } -int threadqueue_init(threadqueue_queue * const threadqueue, int thread_count, int fifo) { +int threadqueue_init(threadqueue_queue_t * const threadqueue, int thread_count, int fifo) { int i; if (pthread_mutex_init(&threadqueue->lock, NULL) != 0) { fprintf(stderr, "pthread_mutex_init failed!\n"); @@ -306,7 +306,7 @@ int threadqueue_init(threadqueue_queue * const threadqueue, int thread_count, in /** * \brief Free a single job from the threadqueue index i, destroying it. */ -static void threadqueue_free_job(threadqueue_queue * const threadqueue, int i) +static void threadqueue_free_job(threadqueue_queue_t * const threadqueue, int i) { #ifdef _DEBUG #if _DEBUG & _DEBUG_PERF_JOB @@ -328,7 +328,7 @@ static void threadqueue_free_job(threadqueue_queue * const threadqueue, int i) FREE_POINTER(threadqueue->queue[i]); } -static void threadqueue_free_jobs(threadqueue_queue * const threadqueue) { +static void threadqueue_free_jobs(threadqueue_queue_t * const threadqueue) { int i; for (i=0; i < threadqueue->queue_count; ++i) { threadqueue_free_job(threadqueue, i); @@ -347,7 +347,7 @@ static void threadqueue_free_jobs(threadqueue_queue * const threadqueue) { #endif } -int threadqueue_finalize(threadqueue_queue * const threadqueue) { +int threadqueue_finalize(threadqueue_queue_t * const threadqueue) { int i; //Flush the queue @@ -428,7 +428,7 @@ int threadqueue_finalize(threadqueue_queue * const threadqueue) { return 1; } -int threadqueue_flush(threadqueue_queue * const threadqueue) { +int threadqueue_flush(threadqueue_queue_t * const threadqueue) { int notdone = 1; //Lock the queue @@ -461,7 +461,7 @@ int threadqueue_flush(threadqueue_queue * const threadqueue) { return 1; } -int threadqueue_waitfor(threadqueue_queue * const threadqueue, threadqueue_job_t * const job) { +int threadqueue_waitfor(threadqueue_queue_t * const threadqueue, threadqueue_job_t * const job) { int job_done = 0; //NULL job is clearly OK :-) @@ -509,7 +509,7 @@ int threadqueue_waitfor(threadqueue_queue * const threadqueue, threadqueue_job_t return 1; } -threadqueue_job_t * threadqueue_submit(threadqueue_queue * const threadqueue, void (*fptr)(void *arg), void *arg, int wait, const char* const debug_description) { +threadqueue_job_t * threadqueue_submit(threadqueue_queue_t * const threadqueue, void (*fptr)(void *arg), void *arg, int wait, const char* const debug_description) { threadqueue_job_t *job; //No lock here... this should be constant if (threadqueue->threads_count == 0) { @@ -624,7 +624,7 @@ int threadqueue_job_dep_add(threadqueue_job_t *job, threadqueue_job_t *depends_o return 1; } -int threadqueue_job_unwait_job(threadqueue_queue * const threadqueue, threadqueue_job_t *job) { +int threadqueue_job_unwait_job(threadqueue_queue_t * const threadqueue, threadqueue_job_t *job) { int ndepends = 0; //NULL job => no threads, nothing to do @@ -649,7 +649,7 @@ int threadqueue_job_unwait_job(threadqueue_queue * const threadqueue, threadqueu } #ifdef _DEBUG -int threadqueue_log(threadqueue_queue * threadqueue, const CLOCK_T *start, const CLOCK_T *stop, const char* debug_description) { +int threadqueue_log(threadqueue_queue_t * threadqueue, const CLOCK_T *start, const CLOCK_T *stop, const char* debug_description) { int i, thread_id = -1; FILE* output; diff --git a/src/threadqueue.h b/src/threadqueue.h index 3584f06e..159c511e 100644 --- a/src/threadqueue.h +++ b/src/threadqueue.h @@ -94,30 +94,30 @@ typedef struct { CLOCK_T *debug_clock_thread_start; CLOCK_T *debug_clock_thread_end; #endif -} threadqueue_queue; +} threadqueue_queue_t; //Init a threadqueue (if fifo, then behave as a FIFO with dependencies, otherwise as a LIFO with dependencies) -int threadqueue_init(threadqueue_queue * threadqueue, int thread_count, int fifo); +int threadqueue_init(threadqueue_queue_t * threadqueue, int thread_count, int fifo); //Add a job to the queue, and returs a threadqueue_job handle. If wait == 1, one has to run threadqueue_job_unwait_job in order to have it run -threadqueue_job_t * threadqueue_submit(threadqueue_queue * threadqueue, void (*fptr)(void *arg), void *arg, int wait, const char* debug_description); +threadqueue_job_t * threadqueue_submit(threadqueue_queue_t * threadqueue, void (*fptr)(void *arg), void *arg, int wait, const char* debug_description); -int threadqueue_job_unwait_job(threadqueue_queue * threadqueue, threadqueue_job_t *job); +int threadqueue_job_unwait_job(threadqueue_queue_t * threadqueue, threadqueue_job_t *job); //Add a dependency between two jobs. int threadqueue_job_dep_add(threadqueue_job_t *job, threadqueue_job_t *depends_on); //Blocking call until the queue is empty. Previously set threadqueue_job handles should not be used anymore -int threadqueue_flush(threadqueue_queue * threadqueue); +int threadqueue_flush(threadqueue_queue_t * threadqueue); //Blocking call until job is executed. Job handles submitted before job should not be used any more as they are removed from the queue. -int threadqueue_waitfor(threadqueue_queue * threadqueue, threadqueue_job_t * job); +int threadqueue_waitfor(threadqueue_queue_t * threadqueue, threadqueue_job_t * job); //Free ressources in a threadqueue -int threadqueue_finalize(threadqueue_queue * threadqueue); +int threadqueue_finalize(threadqueue_queue_t * threadqueue); #ifdef _DEBUG -int threadqueue_log(threadqueue_queue * threadqueue, const CLOCK_T *start, const CLOCK_T *stop, const char* debug_description); +int threadqueue_log(threadqueue_queue_t * threadqueue, const CLOCK_T *start, const CLOCK_T *stop, const char* debug_description); //This macro HAS TO BE at the beginning of a block #define PERFORMANCE_MEASURE_START(mask) CLOCK_T start, stop; if (_DEBUG & mask) GET_TIME(&start)