From 58fe7d147774960e3fb7dbc53a3e5ecf106ebf01 Mon Sep 17 00:00:00 2001 From: sinanmohd Date: Fri, 14 Jun 2024 12:18:40 +0530 Subject: build: init --- include/build.h | 12 ++++++++++++ include/jobs.h | 5 +++++ include/queue.h | 14 ++++++++++++++ 3 files changed, 31 insertions(+) create mode 100644 include/build.h (limited to 'include') 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 +#include + +#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 #include +#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 #include +#include #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 -- cgit v1.2.3