aboutsummaryrefslogblamecommitdiff
path: root/include/queue.h
blob: dd7e4db4ad83e6c354ddd093ac3def7f30a5bed3 (plain) (tree)
1
2
3
4
5
6
7
8
9
                    
                   
                      
                      
 
                 
                 
                        
 






                       

                              
                          
                            

                            











                                                                       
                                                                        


               
#include <pthread.h>
#include <search.h>
#include <semaphore.h>
#include <sys/queue.h>

#include "htab.h"
#include "jobs.h"
#include "solver_util.h"

#ifndef QUEUE_H

typedef enum {
	Q_ITS_OVER = 0,
	Q_SEM_WAIT = 1,
} queue_state_t;

struct queue {
	struct job_clist jobs;
	struct htab *htab;
	struct jobid *jobid;
	sem_t sem;
	queue_state_t state;
	pthread_mutex_t mutex;
};

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, struct htab *htab);

#define QUEUE_H
#endif