about summary refs log tree commit diff
path: root/src/rt/rust_builtin.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/rt/rust_builtin.cpp')
-rw-r--r--src/rt/rust_builtin.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/rt/rust_builtin.cpp b/src/rt/rust_builtin.cpp
index 4b8af7a67b6..a7d6a902231 100644
--- a/src/rt/rust_builtin.cpp
+++ b/src/rt/rust_builtin.cpp
@@ -702,6 +702,11 @@ unpin_task(rust_task *task) {
     task->unpin();
 }
 
+extern "C" CDECL rust_task_id
+get_task_id(rust_task *task) {
+    return task->id;
+}
+
 extern "C" CDECL rust_chan *
 clone_chan(rust_task *task, rust_chan *chan) {
     return chan->clone(task);
@@ -738,6 +743,11 @@ del_port(rust_task *task, rust_port *port) {
     task->deref();
 }
 
+extern "C" CDECL rust_port_id
+get_port_id(rust_task *task, rust_port *port) {
+    return port->id;
+}
+
 extern "C" CDECL rust_chan*
 new_chan(rust_task *task, rust_port *port) {
     rust_scheduler *sched = task->sched;
@@ -776,6 +786,19 @@ chan_send(rust_task *task, rust_chan *chan, void *sptr) {
 }
 
 extern "C" CDECL void
+chan_id_send(rust_task *task, type_desc *t, rust_task_id target_task_id,
+             rust_port_id target_port_id, void *sptr) {
+    // FIXME: make sure this is thread-safe
+    rust_task *target_task = task->kernel->get_task_by_id(target_task_id);
+    if(target_task) {
+        rust_port *port = target_task->get_port_by_id(target_port_id);
+        if(port) {
+            port->remote_chan->send(sptr);
+        }
+    }
+}
+
+extern "C" CDECL void
 port_recv(rust_task *task, uintptr_t *dptr, rust_port *port) {
     {
         scoped_lock with(port->lock);