diff --git a/src/lib/comm.rs b/src/lib/comm.rs index 9c8f20a9a75..44c1a2ce341 100644 --- a/src/lib/comm.rs +++ b/src/lib/comm.rs @@ -132,5 +132,5 @@ fn recv(p: port) -> T { ret rusti::recv(***p) } The channel is bound to the port used to construct it. */ fn chan(p: port) -> chan { - chan_t(task::get_task_id(), rustrt::get_port_id(***p)) + chan_t(task::get_task(), rustrt::get_port_id(***p)) } diff --git a/src/lib/task.rs b/src/lib/task.rs index 6f92ed7ff5e..f90ebe45ed9 100644 --- a/src/lib/task.rs +++ b/src/lib/task.rs @@ -22,7 +22,7 @@ export task_result; export tr_success; export tr_failure; -export get_task_id; +export get_task; export spawn; export spawn_notify; export spawn_joinable; @@ -31,7 +31,7 @@ // these must run on the Rust stack so that they can swap stacks etc: fn task_sleep(time_in_us: uint); fn task_yield(); - fn start_task(id: task_id, closure: *u8); + fn start_task(id: task, closure: *u8); } native "c-stack-cdecl" mod rustrt2 = "rustrt" { @@ -43,7 +43,7 @@ fn set_min_stack(stack_size: uint); fn new_task() -> task_id; - fn drop_task(task: *rust_task); + fn drop_task(task_id: *rust_task); fn get_task_pointer(id: task_id) -> *rust_task; fn migrate_alloc(alloc: *u8, target: task_id); @@ -57,11 +57,11 @@ resource rust_task_ptr(task: *rust_task) { rustrt2::drop_task(task); } -type task = int; -type task_id = task; -type joinable_task = (task_id, comm::port); +type task_id = int; +type task = task_id; +type joinable_task = (task, comm::port); -fn get_task_id() -> task_id { rustrt2::get_task_id() } +fn get_task() -> task { rustrt2::get_task_id() } /** * Hints the scheduler to yield this task for a specified ammount of time. @@ -76,7 +76,7 @@ fn get_task_id() -> task_id { rustrt2::get_task_id() } tag task_notification { exit(task, task_result); } -fn join(task_port: (task_id, comm::port)) -> task_result { +fn join(task_port: joinable_task) -> task_result { let (id, port) = task_port; alt comm::recv::(port) { exit(_id, res) { @@ -96,12 +96,12 @@ fn join(task_port: (task_id, comm::port)) -> task_result { fn set_min_stack(stack_size: uint) { rustrt2::set_min_stack(stack_size); } fn spawn(-data: T, f: fn(T)) -> task { - spawn_inner2(data, f, none) + spawn_inner(data, f, none) } fn spawn_notify(-data: T, f: fn(T), notify: comm::chan) -> task { - spawn_inner2(data, f, some(notify)) + spawn_inner(data, f, some(notify)) } fn spawn_joinable(-data: T, f: fn(T)) -> joinable_task { @@ -120,9 +120,9 @@ fn spawn_joinable(-data: T, f: fn(T)) -> joinable_task { // // After the transition this should all be rewritten. -fn spawn_inner2(-data: T, f: fn(T), +fn spawn_inner(-data: T, f: fn(T), notify: option>) - -> task_id { + -> task { fn wrapper(-data: *u8, f: fn(T)) { let data: ~T = unsafe::reinterpret_cast(data); @@ -140,7 +140,7 @@ fn wrapper(-data: *u8, f: fn(T)) { // It is a hack and needs to be rewritten. fn unsafe_spawn_inner(-thunk: fn@(), notify: option>) -> - task_id unsafe { + task unsafe { let id = rustrt2::new_task(); let raw_thunk: {code: u32, env: u32} = cast(thunk);