summaryrefslogtreecommitdiff
path: root/queue.h
diff options
context:
space:
mode:
authorTom Harley2020-01-24 05:15:35 +0000
committerTom Harley2020-01-24 05:15:35 +0000
commitc9f0de12be31eea463bf022f3eee76490b30f8dc (patch)
treea80718ff00fa2dcb1c52c2af6828feffc7f89d8b /queue.h
downloadparapat-master.tar.gz
parapat-master.zip

Initial commit

HEADmaster
Diffstat (limited to 'queue.h')
-rw-r--r--queue.h25
1 files changed, 25 insertions, 0 deletions
diff --git a/queue.h b/queue.h
new file mode 100644
index 0000000..4ca9b4a
--- /dev/null
+++ b/queue.h
@@ -0,0 +1,25 @@
+/*
+ * vim: ft=c
+ */
+
+#ifndef QUEUE_H
+#define QUEUE_H
+
+#include <semaphore.h>
+#include <pthread.h>
+
+typedef struct {
+ pthread_mutex_t mtx;
+ sem_t size;
+ void *elements[100];
+ int front;
+ int back;
+} queue;
+
+int init_queue(queue *q);
+
+int enqueue(queue *q, void *v);
+int dequeue(queue *q, void **v);
+int pq_close(queue *q);
+
+#endif /* QUEUE_H */