feat: input device subsystem to resolve race condition on polling input
[lunaix-os.git] / lunaix-os / includes / lunaix / ds / waitq.h
diff --git a/lunaix-os/includes/lunaix/ds/waitq.h b/lunaix-os/includes/lunaix/ds/waitq.h
new file mode 100644 (file)
index 0000000..dfeb7c3
--- /dev/null
@@ -0,0 +1,26 @@
+#ifndef __LUNAIX_CODVAR_H
+#define __LUNAIX_CODVAR_H
+
+#include <lunaix/ds/llist.h>
+
+typedef struct waitq
+{
+    struct llist_header waiters;
+} waitq_t;
+
+inline void
+waitq_init(waitq_t* waitq)
+{
+    llist_init_head(&waitq->waiters);
+}
+
+void
+pwait(waitq_t* queue);
+
+void
+pwake_one(waitq_t* queue);
+
+void
+pwake_all(waitq_t* queue);
+
+#endif /* __LUNAIX_CODVAR_H */