diff options
author | sinanmohd <sinan@sinanmohd.com> | 2024-06-14 12:18:40 +0530 |
---|---|---|
committer | sinanmohd <sinan@sinanmohd.com> | 2024-06-14 18:53:40 +0530 |
commit | 58fe7d147774960e3fb7dbc53a3e5ecf106ebf01 (patch) | |
tree | 0b8651b5a69666605125c05ee18ee68bd13308e1 /include | |
parent | 6627adcbc2d2ade8db1fd2ed26e03d37b53fde62 (diff) |
build: init
Diffstat (limited to 'include')
-rw-r--r-- | include/build.h | 12 | ||||
-rw-r--r-- | include/jobs.h | 5 | ||||
-rw-r--r-- | include/queue.h | 14 |
3 files changed, 31 insertions, 0 deletions
diff --git a/include/build.h b/include/build.h new file mode 100644 index 0000000..c51bc5d --- /dev/null +++ b/include/build.h @@ -0,0 +1,12 @@ +#include <pthread.h> +#include <sys/queue.h> + +#include "queue.h" + +struct build_thread { + pthread_t tid; + struct queue *queue; +}; + +void *build_thread_entry(void *queue_thread); +int build_thread_new(struct build_thread **build_thread, struct queue *q); diff --git a/include/jobs.h b/include/jobs.h index be95c57..1044eaa 100644 --- a/include/jobs.h +++ b/include/jobs.h @@ -1,6 +1,8 @@ #include <stdio.h> #include <sys/queue.h> +#ifndef JOBS_H + LIST_HEAD(output_dlist, output); struct output { char *name, *store_path; @@ -23,3 +25,6 @@ int jobs_init(FILE **stream); int job_new(struct job **j, char *name, char *drv_path); void job_free(struct job *j); int job_read(FILE *stream, struct job **jobs); + +#define JOBS_H +#endif diff --git a/include/queue.h b/include/queue.h index ca11614..5f2d5f4 100644 --- a/include/queue.h +++ b/include/queue.h @@ -1,10 +1,20 @@ #include <pthread.h> #include <sys/queue.h> +#include <semaphore.h> #include "jobs.h" +#ifndef QUEUE_H + +typedef enum { + Q_ITS_OVER = 0, + Q_SEM_WAIT = 1, +} queue_state_t; + struct queue { struct job_clist jobs; + sem_t sem; + queue_state_t state; pthread_mutex_t mutex; }; @@ -17,3 +27,7 @@ struct queue_thread { int queue_thread_new(struct queue_thread **queue_thread, FILE *stream); void queue_thread_free(struct queue_thread *queue_thread); void *queue_thread_entry(void *queue_thread); +int queue_pop(struct queue *queue, struct job **job); + +#define QUEUE_H +#endif |