diff options
author | Jean-Francois Mauguit <jfmauguit@mac.com> | 2024-09-24 09:03:25 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-24 09:03:25 -0400 |
commit | bab614c421ed7ae329d26bf028c4a3b1d2450f5a (patch) | |
tree | 12f17f78986871dd2cfb0a56e5e93b545c1ae0d0 /Src/replicant/nu/lfmpscq.h | |
parent | 4bde6044fddf053f31795b9eaccdd2a5a527d21f (diff) | |
parent | 20d28e80a5c861a9d5f449ea911ab75b4f37ad0d (diff) | |
download | winamp-bab614c421ed7ae329d26bf028c4a3b1d2450f5a.tar.gz |
Merge pull request #5 from WinampDesktop/community
Merge to main
Diffstat (limited to 'Src/replicant/nu/lfmpscq.h')
-rw-r--r-- | Src/replicant/nu/lfmpscq.h | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/Src/replicant/nu/lfmpscq.h b/Src/replicant/nu/lfmpscq.h new file mode 100644 index 00000000..c06f3331 --- /dev/null +++ b/Src/replicant/nu/lfmpscq.h @@ -0,0 +1,23 @@ +#pragma once +#include "queue_node.h" + +/* lock free unbounded multiple producer, single consumer queue */ +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct mpscq_struct_t +{ + queue_node_t * volatile head; + queue_node_t *tail; + queue_node_t stub; +} mpscq_t; + +#define MPSCQ_STATIC_INIT(self) {&self.stub, &self.stub, {0}} + +void mpscq_init(mpscq_t* self); +int mpscq_push(mpscq_t *self, queue_node_t *n); +queue_node_t *mpscq_pop(mpscq_t *self); /* returns (queue_node_t *)1 if the queue is busy */ +#ifdef __cplusplus +} +#endif |