Port ID-based channels.
This commit is contained in:
@@ -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;
|
||||
@@ -775,6 +785,19 @@ chan_send(rust_task *task, rust_chan *chan, void *sptr) {
|
||||
chan->send(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) {
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user