73 lines
2.4 KiB
C
73 lines
2.4 KiB
C
![]() |
/* _,.---._ .-._ .--.-. ,--.--------.
|
||
|
* _,..---._ ,-.' , - `. /==/ \ .-._/==/ //==/, - , -\
|
||
|
* /==/, - \ /==/_, , - \|==|, \/ /, |==\ -\\==\.-. - ,-./
|
||
|
* |==| _ _\==| .=. |==|- \| | \==\- \`--`\==\- \
|
||
|
* |==| .=. |==|_ : ;=: - |==| , | -| `--`-' \==\_ \
|
||
|
* |==|,| | -|==| , '=' |==| - _ | |==|- |
|
||
|
* |==| '=' /\==\ - ,_ /|==| /\ , | |==|, |
|
||
|
* |==|-, _`/ '.='. - .' /==/, | |- | /==/ -/
|
||
|
* `-.`.____.' `--`--'' `--`./ `--` `--`--`
|
||
|
* _ __ ,---. .-._ .=-.-. _,.----.
|
||
|
* .-`.' ,`..--.' \ /==/ \ .-._ /==/_ /.' .' - \
|
||
|
* /==/, - \==\-/\ \ |==|, \/ /, /==|, |/==/ , ,-'
|
||
|
* |==| _ .=. /==/-|_\ | |==|- \| ||==| ||==|- | .
|
||
|
* |==| , '=',\==\, - \ |==| , | -||==|- ||==|_ `-' \
|
||
|
* |==|- '..'/==/ - ,| |==| - _ ||==| ,||==| _ , |
|
||
|
* |==|, | /==/- /\ - \|==| /\ , ||==|- |\==\. /
|
||
|
* /==/ - | \==\ _.\=\.-'/==/, | |- |/==/. / `-.`.___.-'
|
||
|
* `--`---' `--` `--`./ `--``--`-`
|
||
|
*
|
||
|
* @(#)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 MQ_H
|
||
|
#define MQ_H 1
|
||
|
|
||
|
#include <pthread.h>
|
||
|
|
||
|
#include "haggis.h"
|
||
|
|
||
|
typedef enum {
|
||
|
NodeCreated,
|
||
|
NodeExtracted,
|
||
|
EndOfArchive,
|
||
|
ArchiveError,
|
||
|
} haggis_message_type;
|
||
|
|
||
|
typedef union {
|
||
|
char *f_name;
|
||
|
int errno;
|
||
|
} haggis_message_body;
|
||
|
|
||
|
struct _mq_node {
|
||
|
struct _mq_node *prev;
|
||
|
struct _mq_node *next;
|
||
|
haggis_message_type tag;
|
||
|
haggis_message_body body;
|
||
|
};
|
||
|
|
||
|
typedef struct _mq_node haggis_msg;
|
||
|
|
||
|
typedef struct {
|
||
|
pthread_cond_t *cond;
|
||
|
size_t count;
|
||
|
pthread_mutex_t *mutex;
|
||
|
haggis_msg *head;
|
||
|
haggis_msg *tail;
|
||
|
} haggis_mq;
|
||
|
|
||
|
int haggis_mq_push(haggis_mq *queue, haggis_msg *msg);
|
||
|
haggis_msg* haggis_mq_pop(haggis_mq *queue);
|
||
|
|
||
|
#endif // !JOBQ_H
|