aboutsummaryrefslogtreecommitdiff
path: root/src/rt/rust_message.h
diff options
context:
space:
mode:
authorMichael Bebenita <[email protected]>2010-07-28 16:24:50 -0700
committerGraydon Hoare <[email protected]>2010-07-28 20:30:29 -0700
commit4ff8e15128f90d4e9e57897c48280c6f82bb8343 (patch)
tree86c3808e729b4f596c3c23e228738d3d25b108bc /src/rt/rust_message.h
parentRename rust_proxy_delegate to maybe_proxy, flesh out logic in it. Add strong-... (diff)
downloadrust-4ff8e15128f90d4e9e57897c48280c6f82bb8343.tar.xz
rust-4ff8e15128f90d4e9e57897c48280c6f82bb8343.zip
Move notification-messages out into their own file and unify into notify_message, make them use proxies, cache task proxies in dom.
Diffstat (limited to 'src/rt/rust_message.h')
-rw-r--r--src/rt/rust_message.h72
1 files changed, 72 insertions, 0 deletions
diff --git a/src/rt/rust_message.h b/src/rt/rust_message.h
new file mode 100644
index 00000000..f0c6bc0a
--- /dev/null
+++ b/src/rt/rust_message.h
@@ -0,0 +1,72 @@
+#ifndef RUST_MESSAGE_H
+#define RUST_MESSAGE_H
+
+/**
+ * Rust messages are used for inter-thread communication. They are enqueued
+ * and allocated in the target domain.
+ */
+
+/**
+ * Abstract base class for all message types.
+ */
+class rust_message : public lock_free_queue_node,
+ public dom_owned<rust_message> {
+public:
+ rust_dom *dom;
+ const char* label;
+private:
+ rust_task *_source;
+protected:
+ rust_task *_target;
+public:
+ rust_message(const char* label, rust_task *source, rust_task *target);
+ virtual ~rust_message();
+
+ /**
+ * We can only access the source task through a proxy, so create one
+ * on demand if we need it.
+ */
+ rust_proxy<rust_task> *get_source_proxy();
+
+ /**
+ * Processes the message in the target domain thread.
+ */
+ virtual void process();
+};
+
+/**
+ * Notify messages are simple argument-less messages.
+ */
+class notify_message : public rust_message {
+public:
+ enum notification_type {
+ KILL, JOIN, WAKEUP
+ };
+
+ const notification_type type;
+
+ notify_message(notification_type type, const char* label,
+ rust_task *source, rust_task *target);
+
+ void process();
+
+ /**
+ * This code executes in the sending domain's thread.
+ */
+ static void
+ send(notification_type type, const char* label, rust_task *source,
+ rust_proxy<rust_task> *target);
+};
+
+//
+// Local Variables:
+// mode: C++
+// fill-column: 78;
+// indent-tabs-mode: nil
+// c-basic-offset: 4
+// buffer-file-coding-system: utf-8-unix
+// compile-command: "make -k -C .. 2>&1 | sed -e 's/\\/x\\//x:\\//g'";
+// End:
+//
+
+#endif /* RUST_MESSAGE_H */