aboutsummaryrefslogtreecommitdiff
path: root/src/rt/rust_message.cpp
diff options
context:
space:
mode:
authorMichael Bebenita <[email protected]>2010-07-28 16:46:13 -0700
committerGraydon Hoare <[email protected]>2010-07-28 20:30:29 -0700
commit4246d567b7a999155524669e3b0419e8f71080b1 (patch)
tree38ab4d3aa04b25e37db9e663890235edf2f3a8a6 /src/rt/rust_message.cpp
parentMove notification-messages out into their own file and unify into notify_mess... (diff)
downloadrust-4246d567b7a999155524669e3b0419e8f71080b1.tar.xz
rust-4246d567b7a999155524669e3b0419e8f71080b1.zip
Move ports out into their own file, add data_message and make communication system use it (and proxies) instead of existing token scheme.
Diffstat (limited to 'src/rt/rust_message.cpp')
-rw-r--r--src/rt/rust_message.cpp32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/rt/rust_message.cpp b/src/rt/rust_message.cpp
index 22f8ffe5..8b396b4d 100644
--- a/src/rt/rust_message.cpp
+++ b/src/rt/rust_message.cpp
@@ -27,6 +27,19 @@ notify_message(notification_type type, const char* label,
rust_message(label, source, target), type(type) {
}
+data_message::
+data_message(uint8_t *buffer, size_t buffer_sz, const char* label,
+ rust_task *source, rust_task *target, rust_port *port) :
+ rust_message(label, source, target),
+ _buffer_sz(buffer_sz), _port(port) {
+ _buffer = (uint8_t *)malloc(buffer_sz);
+ memcpy(_buffer, buffer, buffer_sz);
+}
+
+data_message::~data_message() {
+ free (_buffer);
+}
+
/**
* Sends a message to the target task via a proxy. The message is allocated
* in the target task domain along with a proxy which points back to the
@@ -63,6 +76,25 @@ void notify_message::process() {
}
}
+void data_message::
+send(uint8_t *buffer, size_t buffer_sz, const char* label, rust_task *source,
+ rust_proxy<rust_task> *target, rust_proxy<rust_port> *port) {
+
+ rust_task *target_task = target->delegate();
+ rust_port *target_port = port->delegate();
+ rust_dom *target_domain = target_task->dom;
+ data_message *message = new (target_domain)
+ data_message(buffer, buffer_sz, label, source,
+ target_task, target_port);
+ target_domain->send_message(message);
+}
+
+void data_message::process() {
+ _port->remote_channel->buffer.enqueue(_buffer);
+ _port->remote_channel->transmit();
+ _target->log(rust_log::COMM, "<=== received data via message ===");
+}
+
//
// Local Variables:
// mode: C++