Skip to content

Commit 561511e

Browse files
committed
core: Channels are just port ids
1 parent c414b78 commit 561511e

File tree

5 files changed

+17
-27
lines changed

5 files changed

+17
-27
lines changed

src/libcore/comm.rs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,9 @@ enum rust_port {}
3838

3939
#[abi = "cdecl"]
4040
native mod rustrt {
41-
fn get_task_id() -> task_id;
42-
fn chan_id_send<T: send>(t: *sys::type_desc,
43-
target_task: task_id, target_port: port_id,
44-
data: T) -> libc::uintptr_t;
41+
fn rust_port_id_send<T: send>(t: *sys::type_desc,
42+
target_port: port_id,
43+
data: T) -> libc::uintptr_t;
4544

4645
fn new_port(unit_sz: libc::size_t) -> *rust_port;
4746
fn del_port(po: *rust_port);
@@ -63,7 +62,6 @@ native mod rusti {
6362
fn call_with_retptr<T: send>(&&f: fn@(*uint)) -> T;
6463
}
6564

66-
type task_id = int;
6765
type port_id = int;
6866

6967
// It's critical that this only have one variant, so it has a record
@@ -79,7 +77,7 @@ data will be silently dropped. Channels may be duplicated and
7977
themselves transmitted over other channels.
8078
"]
8179
enum chan<T: send> {
82-
chan_t(task_id, port_id)
80+
chan_t(port_id)
8381
}
8482

8583
resource port_ptr<T: send>(po: *rust_port) {
@@ -119,8 +117,8 @@ Sends data over a channel. The sent data is moved into the channel,
119117
whereupon the caller loses access to it.
120118
"]
121119
fn send<T: send>(ch: chan<T>, -data: T) {
122-
let chan_t(t, p) = ch;
123-
let res = rustrt::chan_id_send(sys::get_type_desc::<T>(), t, p, data);
120+
let chan_t(p) = ch;
121+
let res = rustrt::rust_port_id_send(sys::get_type_desc::<T>(), p, data);
124122
if res != 0u unsafe {
125123
// Data sent successfully
126124
unsafe::leak(data);
@@ -217,7 +215,7 @@ Constructs a channel. The channel is bound to the port used to
217215
construct it.
218216
"]
219217
fn chan<T: send>(p: port<T>) -> chan<T> {
220-
chan_t(rustrt::get_task_id(), rustrt::get_port_id(***p))
218+
chan_t(rustrt::get_port_id(***p))
221219
}
222220

223221
#[test]

src/rt/rust_builtin.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -444,8 +444,8 @@ rust_new_task_in_sched(rust_sched_id id) {
444444
}
445445

446446
extern "C" CDECL void
447-
rust_task_config_notify(rust_task *target, chan_handle *chan) {
448-
target->config_notify(*chan);
447+
rust_task_config_notify(rust_task *target, rust_port_id *port) {
448+
target->config_notify(*port);
449449
}
450450

451451
extern "C" rust_task *
@@ -503,13 +503,11 @@ get_port_id(rust_port *port) {
503503
}
504504

505505
extern "C" CDECL uintptr_t
506-
chan_id_send(type_desc *t, rust_task_id target_task_id,
507-
rust_port_id target_port_id, void *sptr) {
506+
rust_port_id_send(type_desc *t, rust_port_id target_port_id, void *sptr) {
508507
bool sent = false;
509508
rust_task *task = rust_task_thread::get_task();
510509

511-
LOG(task, comm, "chan_id_send task: 0x%" PRIxPTR
512-
" port: 0x%" PRIxPTR, (uintptr_t) target_task_id,
510+
LOG(task, comm, "rust_port_id*_send port: 0x%" PRIxPTR,
513511
(uintptr_t) target_port_id);
514512

515513
rust_port *port = task->kernel->get_port_by_id(target_port_id);

src/rt/rust_task.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,7 @@ rust_task::notify(bool success) {
475475
// FIXME (1078) Do this in rust code
476476
if(notify_enabled) {
477477
rust_port *target_port =
478-
kernel->get_port_by_id(notify_chan.port);
478+
kernel->get_port_by_id(notify_port);
479479
if(target_port) {
480480
task_notification msg;
481481
msg.id = id;
@@ -719,9 +719,9 @@ rust_task::delete_all_stacks() {
719719
}
720720

721721
void
722-
rust_task::config_notify(chan_handle chan) {
722+
rust_task::config_notify(rust_port_id port) {
723723
notify_enabled = true;
724-
notify_chan = chan;
724+
notify_port = port;
725725
}
726726

727727
/*

src/rt/rust_task.h

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,6 @@
1818
#include "rust_stack.h"
1919
#include "rust_port_selector.h"
2020

21-
// Corresponds to the rust chan (currently _chan) type.
22-
struct chan_handle {
23-
rust_task_id task;
24-
rust_port_id port;
25-
};
26-
2721
struct rust_box;
2822

2923
struct frame_glue_fns {
@@ -56,7 +50,7 @@ rust_task : public kernel_owned<rust_task>, rust_cond
5650

5751
rust_task_id id;
5852
bool notify_enabled;
59-
chan_handle notify_chan;
53+
rust_port_id notify_port;
6054

6155
context ctx;
6256
stk_seg *stk;
@@ -209,7 +203,7 @@ rust_task : public kernel_owned<rust_task>, rust_cond
209203
void check_stack_canary();
210204
void delete_all_stacks();
211205

212-
void config_notify(chan_handle chan);
206+
void config_notify(rust_port_id port);
213207

214208
void call_on_c_stack(void *args, void *fn_ptr);
215209
void call_on_rust_stack(void *args, void *fn_ptr);

src/rt/rustrt.def.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
chan_id_send
21
check_claims
32
debug_box
43
debug_fn
@@ -16,6 +15,7 @@ new_port
1615
new_task
1716
port_recv
1817
precise_time_ns
18+
rust_port_id_send
1919
rust_port_select
2020
rand_free
2121
rand_new

0 commit comments

Comments
 (0)