aboutsummaryrefslogtreecommitdiff
path: root/include/queue.h
blob: e6178e2f392be778c8393f88d191ebf9b3821925 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include <pthread.h>
#include <search.h>
#include <semaphore.h>
#include <stdint.h>
#include <sys/queue.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;
	struct job *htab;

	/* solver */
	struct jobid *jobid;
	int32_t resources;
};

struct queue_thread {
	pthread_t tid;
	struct queue *queue;
	FILE *stream;
};

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);
int queue_isempty(struct job_clist *jobs);

#define QUEUE_H
#endif