This commit is contained in:
Nikolaj
2021-10-26 16:12:26 +02:00
parent a988405fd3
commit 456adc7611
11 changed files with 418 additions and 327 deletions

View File

@ -4,25 +4,27 @@
#include <pthread.h>
struct job_queue {
int dummy;
int capacity;
int size;
void* jobs;
};
// Initialise a job queue with the given capacity. The queue starts out
// empty. Returns non-zero on error.
// Initialise a job queue with the given capacity. The queue starts out
// empty. Returns non-zero on error.
int job_queue_init(struct job_queue *job_queue, int capacity);
// Destroy the job queue. Blocks until the queue is empty before it
// Destroy the job queue. Blocks until the queue is empty before it
// is destroyed.
int job_queue_destroy(struct job_queue *job_queue);
// Push an element onto the end of the job queue. Blocks if the
// job_queue is full (its size is equal to its capacity). Returns
// non-zero on error. It is an error to push a job onto a queue that
// Push an element onto the end of the job queue. Blocks if the
// job_queue is full (its size is equal to its capacity). Returns
// non-zero on error. It is an error to push a job onto a queue that
// has been destroyed.
int job_queue_push(struct job_queue *job_queue, void *data);
// Pop an element from the front of the job queue. Blocks if the
// job_queue contains zero elements. Returns non-zero on error. If
// Pop an element from the front of the job queue. Blocks if the
// job_queue contains zero elements. Returns non-zero on error. If
// job_queue_destroy() has been called (possibly after the call to
// job_queue_pop() blocked), this function will return -1.
int job_queue_pop(struct job_queue *job_queue, void **data);