summaryrefslogtreecommitdiffstats
path: root/src/mpq.h
diff options
context:
space:
mode:
authorMatt Dunwoodie <ncon@mail.noconroy.net>2019-06-11 20:41:59 +1000
committerMatt Dunwoodie <ncon@mail.noconroy.net>2019-06-11 20:41:59 +1000
commit5445b875ea54aca46d45547f06c2910a60edf8bb (patch)
tree90943552a2bdc48e9c81db5d015fbd5f50efc588 /src/mpq.h
parentRemove state from ifconfig interface (diff)
downloadwireguard-openbsd-5445b875ea54aca46d45547f06c2910a60edf8bb.tar.xz
wireguard-openbsd-5445b875ea54aca46d45547f06c2910a60edf8bb.zip
staging
Diffstat (limited to 'src/mpq.h')
-rw-r--r--src/mpq.h43
1 files changed, 43 insertions, 0 deletions
diff --git a/src/mpq.h b/src/mpq.h
new file mode 100644
index 00000000000..2418d90973a
--- /dev/null
+++ b/src/mpq.h
@@ -0,0 +1,43 @@
+#ifndef _MPQ_H_
+#define _MPQ_H_
+
+#include <sys/mutex.h>
+#include <sys/task.h>
+#include <sys/queue.h>
+
+struct mpq_item {
+ TAILQ_ENTRY(mpq_item) i_worker;
+ TAILQ_ENTRY(mpq_item) i_serial;
+ struct cond i_cond;
+ enum mpq_istate {
+ MPQ_ITEM_WAITING,
+ MPQ_ITEM_PROCESSED,
+ MPQ_ITEM_BARRIER,
+ } i_state;
+ void *i_val;
+};
+
+struct mpq {
+ struct mutex q_mtx;
+ struct mutex q_serial;
+ struct taskq *q_taskq;
+
+ size_t q_max;
+ size_t q_len;
+
+ struct task q_worker_task;
+ struct task q_serial_task;
+
+ void (*q_worker_fn)(void *);
+ void (*q_serial_fn)(void *);
+
+ TAILQ_HEAD(, mpq_item) q_worker_items;
+ TAILQ_HEAD(, mpq_item) q_serial_items;
+};
+
+void mpq_init(struct mpq *, struct taskq *, void (*)(void *), void (*)(void *), size_t);
+int mpq_add(struct mpq *, void *);
+int mpq_active(struct mpq *);
+size_t mpq_len(struct mpq *);
+
+#endif /* _MPQ_H_ */