summaryrefslogtreecommitdiffstats
path: root/lock_free_queue.h
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2009-11-01 19:54:13 +0100
committerJérémy Zurcher <jeremy@asynk.ch>2009-11-01 19:54:13 +0100
commit88fed6a7409411c9ab26151bb757de6f95063e72 (patch)
tree32b4f03eeb4da188158db26f5c6ea7ec94ae5b90 /lock_free_queue.h
downloadlock_free-88fed6a7409411c9ab26151bb757de6f95063e72.zip
lock_free-88fed6a7409411c9ab26151bb757de6f95063e72.tar.gz
initial commit
Diffstat (limited to 'lock_free_queue.h')
-rw-r--r--lock_free_queue.h31
1 files changed, 31 insertions, 0 deletions
diff --git a/lock_free_queue.h b/lock_free_queue.h
new file mode 100644
index 0000000..ac8a859
--- /dev/null
+++ b/lock_free_queue.h
@@ -0,0 +1,31 @@
+/*
+ * File : lock_free_queue.c
+ * Author : Jérémy Zurcher <jeremy@asynk.ch>
+ * Date : 01/11/09
+ * License : stolen from http://www.cs.rochester.edu/~scott/papers/1996_PODC_queues.pdf
+ */
+
+struct node;
+
+typedef union pointer {
+ struct {
+ volatile struct node *ptr;
+ volatile unsigned int count;
+ } split;
+ volatile unsigned long long concat;
+} pointer_t;
+
+typedef struct node {
+ void *data;
+ pointer_t next;
+} node_t;
+
+typedef struct queue {
+ pointer_t head;
+ pointer_t tail;
+} lfq_t;
+
+void init( lfq_t *q );
+void enqueue( lfq_t *q, void *data );
+void* dequeue( lfq_t *q );
+