about summary refs log tree commit diff
path: root/src/rt/sync/interrupt_transparent_queue.h
diff options
context:
space:
mode:
authorMichael Bebenita <mbebenita@mozilla.com>2010-08-24 21:06:56 -0700
committerMichael Bebenita <mbebenita@mozilla.com>2010-08-24 21:07:14 -0700
commit64ff82ecf98ceb4725f0f51c73e23d1efc2160bc (patch)
tree6a6ae7452066716947c4d262eb72041a6a11cb95 /src/rt/sync/interrupt_transparent_queue.h
parentd9fe885ba5e9d67e031389eeb9a14039f9eb5287 (diff)
Implemented an lock free queue based on this paper http://www.cs.rochester.edu/~scott/papers/1996_PODC_queues.pdf, the "lock free queue" we had before wasn't lock free at all.
Diffstat (limited to 'src/rt/sync/interrupt_transparent_queue.h')
-rw-r--r--src/rt/sync/interrupt_transparent_queue.h22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/rt/sync/interrupt_transparent_queue.h b/src/rt/sync/interrupt_transparent_queue.h
new file mode 100644
index 00000000000..7c02d0c8388
--- /dev/null
+++ b/src/rt/sync/interrupt_transparent_queue.h
@@ -0,0 +1,22 @@
+#ifndef INTERRUPT_TRANSPARENT_QUEUE_H
+#define INTERRUPT_TRANSPARENT_QUEUE_H
+
+#include "spin_lock.h"
+
+class interrupt_transparent_queue_node {
+public:
+    interrupt_transparent_queue_node *next;
+    interrupt_transparent_queue_node();
+};
+
+class interrupt_transparent_queue : interrupt_transparent_queue_node {
+    spin_lock lock;
+    interrupt_transparent_queue_node *_tail;
+public:
+    interrupt_transparent_queue();
+    void enqueue(interrupt_transparent_queue_node *item);
+    interrupt_transparent_queue_node *dequeue();
+    bool is_empty();
+};
+
+#endif /* INTERRUPT_TRANSPARENT_QUEUE_H */