aboutsummaryrefslogtreecommitdiff
path: root/src/rt/rust_dom.cpp
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/rust_dom.cpp
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/rust_dom.cpp')
-rw-r--r--src/rt/rust_dom.cpp12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/rt/rust_dom.cpp b/src/rt/rust_dom.cpp
index ce6bebf3..dc42286d 100644
--- a/src/rt/rust_dom.cpp
+++ b/src/rt/rust_dom.cpp
@@ -301,12 +301,14 @@ void rust_dom::send_message(rust_message *message) {
/**
* Drains and processes incoming pending messages.
*/
-void rust_dom::drain_incoming_message_queue() {
+void rust_dom::drain_incoming_message_queue(bool process) {
rust_message *message;
- while ((message = (rust_message *) _incoming_message_queue.dequeue())) {
+ while (_incoming_message_queue.dequeue(&message)) {
log(rust_log::COMM, "<== processing incoming message \"%s\" 0x%"
PRIxPTR, message->label, message);
- message->process();
+ if (process) {
+ message->process();
+ }
message->~rust_message();
this->synchronized_region.free(message);
}
@@ -454,7 +456,7 @@ rust_dom::start_main_loop()
while (n_live_tasks() > 0) {
A(this, is_deadlocked() == false, "deadlock");
- drain_incoming_message_queue();
+ drain_incoming_message_queue(true);
rust_task *scheduled_task = schedule_task();
@@ -519,7 +521,7 @@ rust_dom::start_main_loop()
}
sync::yield();
} else {
- drain_incoming_message_queue();
+ drain_incoming_message_queue(true);
}
reap_dead_tasks();
}