seahag/include/jobq.h

68 lines
2.4 KiB
C
Raw Normal View History

2023-07-29 06:28:33 -04:00
/* _,.---._ .-._ .--.-. ,--.--------.
* _,..---._ ,-.' , - `. /==/ \ .-._/==/ //==/, - , -\
* /==/, - \ /==/_, , - \|==|, \/ /, |==\ -\\==\.-. - ,-./
* |==| _ _\==| .=. |==|- \| | \==\- \`--`\==\- \
* |==| .=. |==|_ : ;=: - |==| , | -| `--`-' \==\_ \
* |==|,| | -|==| , '=' |==| - _ | |==|- |
* |==| '=' /\==\ - ,_ /|==| /\ , | |==|, |
* |==|-, _`/ '.='. - .' /==/, | |- | /==/ -/
* `-.`.____.' `--`--'' `--`./ `--` `--`--`
* _ __ ,---. .-._ .=-.-. _,.----.
* .-`.' ,`..--.' \ /==/ \ .-._ /==/_ /.' .' - \
* /==/, - \==\-/\ \ |==|, \/ /, /==|, |/==/ , ,-'
* |==| _ .=. /==/-|_\ | |==|- \| ||==| ||==|- | .
* |==| , '=',\==\, - \ |==| , | -||==|- ||==|_ `-' \
* |==|- '..'/==/ - ,| |==| - _ ||==| ,||==| _ , |
* |==|, | /==/- /\ - \|==| /\ , ||==|- |\==\. /
* /==/ - | \==\ _.\=\.-'/==/, | |- |/==/. / `-.`.___.-'
* `--`---' `--` `--`./ `--``--`-`
*
* @(#)Copyright (c) 2023, Nathan D. Fisher.
*
* This is free software. It comes with NO WARRANTY.
* Permission to use, modify and distribute this source code
* is granted subject to the following conditions.
* 1/ that the above copyright notice and this notice
* are preserved in all copies and that due credit be given
* to the author.
* 2/ that any changes to this code are clearly commented
* as such so that the author does not get blamed for bugs
* other than his own.
*/
#ifndef JOBQ_H
#define JOBQ_H
#include <pthread.h>
#include <stddef.h>
2023-07-29 06:28:33 -04:00
#include <stdlib.h>
#include <sys/_pthreadtypes.h>
2023-07-29 06:28:33 -04:00
#include "haggis.h"
typedef union {
haggis_node *node;
char *f_name;
} haggis_job;
struct _job_node {
struct _job_node *prev;
haggis_job *job;
struct _job_node *next;
2023-07-29 06:28:33 -04:00
};
typedef struct _job_node haggis_jobq_node;
2023-07-29 06:28:33 -04:00
typedef struct {
pthread_cond_t *cond;
size_t count;
2023-07-29 06:28:33 -04:00
pthread_mutex_t *mutex;
haggis_jobq_node *head;
haggis_jobq_node *tail;
} haggis_jobq;
int haggis_jobq_push(haggis_jobq *queue, haggis_job *job);
haggis_job* haggis_jobq_pop(haggis_jobq *queue);
2023-07-29 06:28:33 -04:00
#endif // !JOBQ_H