aboutsummaryrefslogtreecommitdiff
path: root/Src/replicant/nu/LockFreeFIFO.h
diff options
context:
space:
mode:
authorJef <jef@targetspot.com>2024-09-24 08:54:57 -0400
committerJef <jef@targetspot.com>2024-09-24 08:54:57 -0400
commit20d28e80a5c861a9d5f449ea911ab75b4f37ad0d (patch)
tree12f17f78986871dd2cfb0a56e5e93b545c1ae0d0 /Src/replicant/nu/LockFreeFIFO.h
parent537bcbc86291b32fc04ae4133ce4d7cac8ebe9a7 (diff)
downloadwinamp-20d28e80a5c861a9d5f449ea911ab75b4f37ad0d.tar.gz
Initial community commit
Diffstat (limited to 'Src/replicant/nu/LockFreeFIFO.h')
-rw-r--r--Src/replicant/nu/LockFreeFIFO.h34
1 files changed, 34 insertions, 0 deletions
diff --git a/Src/replicant/nu/LockFreeFIFO.h b/Src/replicant/nu/LockFreeFIFO.h
new file mode 100644
index 00000000..598cfaeb
--- /dev/null
+++ b/Src/replicant/nu/LockFreeFIFO.h
@@ -0,0 +1,34 @@
+#pragma once
+#include "queue_node.h"
+/* Algorithm taken from
+Lock-Free Techniques for Concurrent Access to Shared Objects
+Dominique Fober, Yann Orlarey, Stephane Letz
+http://www.grame.fr/Ressources/pub/LockFree.pdf
+http://nedko.arnaudov.name/soft/L17_Fober.pdf
+http://www.grame.fr/Ressources/pub/TR-050523.pdf
+This implementation (c) 2010 Nullsoft, Inc.
+*/
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+struct FIFO_POINTER
+{
+ queue_node_t *fifo_node_t;
+ size_t count;
+};
+
+struct fifo_t
+{
+ FIFO_POINTER head; // _head pointer and total count of pop operations (ocount)
+ FIFO_POINTER tail; // _tail pointer and total count of push operations (icount)
+ queue_node_t dummy;
+ size_t count;
+};
+void fifo_init(fifo_t *fifo);
+void fifo_push(fifo_t *fifo, queue_node_t *cl);
+queue_node_t *fifo_pop(fifo_t *fifo);
+#ifdef __cplusplus
+}
+#endif \ No newline at end of file