aboutsummaryrefslogtreecommitdiff
path: root/src/rt/sync/interrupt_transparent_queue.h
diff options
context:
space:
mode:
authorMichael Bebenita <[email protected]>2010-08-24 21:06:56 -0700
committerMichael Bebenita <[email protected]>2010-08-24 21:07:14 -0700
commit64ff82ecf98ceb4725f0f51c73e23d1efc2160bc (patch)
tree6a6ae7452066716947c4d262eb72041a6a11cb95 /src/rt/sync/interrupt_transparent_queue.h
parentComment on env var required for std.dbg to do any logging. (diff)
downloadrust-64ff82ecf98ceb4725f0f51c73e23d1efc2160bc.tar.xz
rust-64ff82ecf98ceb4725f0f51c73e23d1efc2160bc.zip
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 00000000..7c02d0c8
--- /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 */