aboutsummaryrefslogtreecommitdiff
path: root/Src/replicant/nu/win-x86/LockFreeLIFO.h
diff options
context:
space:
mode:
authorJean-Francois Mauguit <jfmauguit@mac.com>2024-09-24 09:03:25 -0400
committerGitHub <noreply@github.com>2024-09-24 09:03:25 -0400
commitbab614c421ed7ae329d26bf028c4a3b1d2450f5a (patch)
tree12f17f78986871dd2cfb0a56e5e93b545c1ae0d0 /Src/replicant/nu/win-x86/LockFreeLIFO.h
parent4bde6044fddf053f31795b9eaccdd2a5a527d21f (diff)
parent20d28e80a5c861a9d5f449ea911ab75b4f37ad0d (diff)
downloadwinamp-bab614c421ed7ae329d26bf028c4a3b1d2450f5a.tar.gz
Merge pull request #5 from WinampDesktop/community
Merge to main
Diffstat (limited to 'Src/replicant/nu/win-x86/LockFreeLIFO.h')
-rw-r--r--Src/replicant/nu/win-x86/LockFreeLIFO.h31
1 files changed, 31 insertions, 0 deletions
diff --git a/Src/replicant/nu/win-x86/LockFreeLIFO.h b/Src/replicant/nu/win-x86/LockFreeLIFO.h
new file mode 100644
index 00000000..90ba9d33
--- /dev/null
+++ b/Src/replicant/nu/win-x86/LockFreeLIFO.h
@@ -0,0 +1,31 @@
+#pragma once
+#include "foundation/types.h"
+#include "nu/queue_node.h"
+#include "foundation/align.h"
+/* lock free stack object
+multiple threads can push and pop without locking
+note that order is not guaranteed. that is, if Thread 1 calls Insert before Thread 2, Thread 2's item might still make it in before.
+*/
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+ typedef NALIGN(8) struct lifo_struct_t
+ {
+ volatile queue_node_t *head;
+ uint32_t aba;
+ } lifo_t;
+
+ /* use this to allocate an object that will go into this */
+ queue_node_t *lifo_malloc(size_t bytes);
+ void lifo_free(queue_node_t *ptr);
+
+ void lifo_init(lifo_t *lifo);
+ void lifo_push(lifo_t *lifo, queue_node_t *cl);
+ queue_node_t *lifo_pop(lifo_t *lifo);
+
+
+
+#ifdef __cplusplus
+}
+#endif