Lock acquisition order:
More...
#include "global.h"
#include "threadqueue.h"
#include <errno.h>
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "threads.h"
- When locking a job and its dependency, the dependecy must be locked first and then the job depending on it.
- When locking a job and the thread queue, the thread queue must be locked first and then the job.
- When accessing threadqueue_job_t.next, the thread queue must be locked.
◆ PTHREAD_COND_BROADCAST
#define PTHREAD_COND_BROADCAST |
( |
|
c | ) |
|
Value:
return 0; \
}
#define MAX_TILES_PER_DIM
Definition global.h:232
◆ PTHREAD_COND_SIGNAL
◆ PTHREAD_COND_WAIT
◆ PTHREAD_LOCK
◆ PTHREAD_UNLOCK
◆ THREADQUEUE_LIST_REALLOC_SIZE
#define THREADQUEUE_LIST_REALLOC_SIZE 32 |
◆ threadqueue_job_state
Enumerator |
---|
THREADQUEUE_JOB_STATE_PAUSED | Job has been submitted, but is not allowed to run yet.
|
THREADQUEUE_JOB_STATE_WAITING | Job is waiting for dependencies.
|
THREADQUEUE_JOB_STATE_READY | Job is ready to run.
|
THREADQUEUE_JOB_STATE_RUNNING | Job is running.
|
THREADQUEUE_JOB_STATE_DONE | Job is completed.
|
◆ kvz_threadqueue_copy_ref()
Increment reference count and return the job.
◆ kvz_threadqueue_free()
- Returns
- 1 on success, 0 on failure
◆ kvz_threadqueue_free_job()
Decrement reference count of the job. If no references exist any more, deallocate associated memory and destroy mutexes.
Sets the job pointer to NULL.
◆ kvz_threadqueue_init()
- Returns
- 1 on success, 0 on failure
◆ kvz_threadqueue_job_create()
The job is created in a paused state. Function kvz_threadqueue_submit must be called on the job in order to have it run.
- Returns
- pointer to the job, or NULL on failure
◆ kvz_threadqueue_job_dep_add()
- Parameters
-
job | job that should be executed after dependency |
dependency | job that should be executed before job |
- Returns
- 1 on success, 0 on failure
◆ kvz_threadqueue_stop()
Block until all threads have stopped.
- Returns
- 1 on success, 0 on failure
◆ kvz_threadqueue_submit()
◆ kvz_threadqueue_waitfor()
- Returns
- 1 on success, 0 on failure
◆ threadqueue_pop_job()
The caller must have locked the thread queue. The calling function receives the ownership of the job.
◆ threadqueue_push_job()
The caller must have locked the thread queue and the job. This function takes the ownership of the job.
◆ threadqueue_worker()