core: Channels are just port ids
This commit is contained in:
parent
c414b78afe
commit
561511e628
@ -38,10 +38,9 @@ enum rust_port {}
|
||||
|
||||
#[abi = "cdecl"]
|
||||
native mod rustrt {
|
||||
fn get_task_id() -> task_id;
|
||||
fn chan_id_send<T: send>(t: *sys::type_desc,
|
||||
target_task: task_id, target_port: port_id,
|
||||
data: T) -> libc::uintptr_t;
|
||||
fn rust_port_id_send<T: send>(t: *sys::type_desc,
|
||||
target_port: port_id,
|
||||
data: T) -> libc::uintptr_t;
|
||||
|
||||
fn new_port(unit_sz: libc::size_t) -> *rust_port;
|
||||
fn del_port(po: *rust_port);
|
||||
@ -63,7 +62,6 @@ fn rust_port_select(dptr: **rust_port, ports: **rust_port,
|
||||
fn call_with_retptr<T: send>(&&f: fn@(*uint)) -> T;
|
||||
}
|
||||
|
||||
type task_id = int;
|
||||
type port_id = int;
|
||||
|
||||
// It's critical that this only have one variant, so it has a record
|
||||
@ -79,7 +77,7 @@ fn rust_port_select(dptr: **rust_port, ports: **rust_port,
|
||||
themselves transmitted over other channels.
|
||||
"]
|
||||
enum chan<T: send> {
|
||||
chan_t(task_id, port_id)
|
||||
chan_t(port_id)
|
||||
}
|
||||
|
||||
resource port_ptr<T: send>(po: *rust_port) {
|
||||
@ -119,8 +117,8 @@ enum port<T: send> { port_t(@port_ptr<T>) }
|
||||
whereupon the caller loses access to it.
|
||||
"]
|
||||
fn send<T: send>(ch: chan<T>, -data: T) {
|
||||
let chan_t(t, p) = ch;
|
||||
let res = rustrt::chan_id_send(sys::get_type_desc::<T>(), t, p, data);
|
||||
let chan_t(p) = ch;
|
||||
let res = rustrt::rust_port_id_send(sys::get_type_desc::<T>(), p, data);
|
||||
if res != 0u unsafe {
|
||||
// Data sent successfully
|
||||
unsafe::leak(data);
|
||||
@ -217,7 +215,7 @@ fn peek<T: send>(p: port<T>) -> bool {
|
||||
construct it.
|
||||
"]
|
||||
fn chan<T: send>(p: port<T>) -> chan<T> {
|
||||
chan_t(rustrt::get_task_id(), rustrt::get_port_id(***p))
|
||||
chan_t(rustrt::get_port_id(***p))
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -444,8 +444,8 @@ rust_new_task_in_sched(rust_sched_id id) {
|
||||
}
|
||||
|
||||
extern "C" CDECL void
|
||||
rust_task_config_notify(rust_task *target, chan_handle *chan) {
|
||||
target->config_notify(*chan);
|
||||
rust_task_config_notify(rust_task *target, rust_port_id *port) {
|
||||
target->config_notify(*port);
|
||||
}
|
||||
|
||||
extern "C" rust_task *
|
||||
@ -503,13 +503,11 @@ get_port_id(rust_port *port) {
|
||||
}
|
||||
|
||||
extern "C" CDECL uintptr_t
|
||||
chan_id_send(type_desc *t, rust_task_id target_task_id,
|
||||
rust_port_id target_port_id, void *sptr) {
|
||||
rust_port_id_send(type_desc *t, rust_port_id target_port_id, void *sptr) {
|
||||
bool sent = false;
|
||||
rust_task *task = rust_task_thread::get_task();
|
||||
|
||||
LOG(task, comm, "chan_id_send task: 0x%" PRIxPTR
|
||||
" port: 0x%" PRIxPTR, (uintptr_t) target_task_id,
|
||||
LOG(task, comm, "rust_port_id*_send port: 0x%" PRIxPTR,
|
||||
(uintptr_t) target_port_id);
|
||||
|
||||
rust_port *port = task->kernel->get_port_by_id(target_port_id);
|
||||
|
@ -475,7 +475,7 @@ rust_task::notify(bool success) {
|
||||
// FIXME (1078) Do this in rust code
|
||||
if(notify_enabled) {
|
||||
rust_port *target_port =
|
||||
kernel->get_port_by_id(notify_chan.port);
|
||||
kernel->get_port_by_id(notify_port);
|
||||
if(target_port) {
|
||||
task_notification msg;
|
||||
msg.id = id;
|
||||
@ -719,9 +719,9 @@ rust_task::delete_all_stacks() {
|
||||
}
|
||||
|
||||
void
|
||||
rust_task::config_notify(chan_handle chan) {
|
||||
rust_task::config_notify(rust_port_id port) {
|
||||
notify_enabled = true;
|
||||
notify_chan = chan;
|
||||
notify_port = port;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -18,12 +18,6 @@
|
||||
#include "rust_stack.h"
|
||||
#include "rust_port_selector.h"
|
||||
|
||||
// Corresponds to the rust chan (currently _chan) type.
|
||||
struct chan_handle {
|
||||
rust_task_id task;
|
||||
rust_port_id port;
|
||||
};
|
||||
|
||||
struct rust_box;
|
||||
|
||||
struct frame_glue_fns {
|
||||
@ -56,7 +50,7 @@ rust_task : public kernel_owned<rust_task>, rust_cond
|
||||
|
||||
rust_task_id id;
|
||||
bool notify_enabled;
|
||||
chan_handle notify_chan;
|
||||
rust_port_id notify_port;
|
||||
|
||||
context ctx;
|
||||
stk_seg *stk;
|
||||
@ -209,7 +203,7 @@ public:
|
||||
void check_stack_canary();
|
||||
void delete_all_stacks();
|
||||
|
||||
void config_notify(chan_handle chan);
|
||||
void config_notify(rust_port_id port);
|
||||
|
||||
void call_on_c_stack(void *args, void *fn_ptr);
|
||||
void call_on_rust_stack(void *args, void *fn_ptr);
|
||||
|
@ -1,4 +1,3 @@
|
||||
chan_id_send
|
||||
check_claims
|
||||
debug_box
|
||||
debug_fn
|
||||
@ -16,6 +15,7 @@ new_port
|
||||
new_task
|
||||
port_recv
|
||||
precise_time_ns
|
||||
rust_port_id_send
|
||||
rust_port_select
|
||||
rand_free
|
||||
rand_new
|
||||
|
Loading…
Reference in New Issue
Block a user