rt: Remove remaining uses of rust_kernel::get_task_by_id
This commit is contained in:
parent
b278d675a2
commit
1366d65660
@ -487,7 +487,7 @@ fn spawn_raw(opts: task_opts, +f: fn~()) unsafe {
|
||||
let fptr = ptr::addr_of(f);
|
||||
let closure: *rust_closure = unsafe::reinterpret_cast(fptr);
|
||||
|
||||
let task_id = alt opts.sched {
|
||||
let new_task = alt opts.sched {
|
||||
none {
|
||||
rustrt::new_task()
|
||||
}
|
||||
@ -498,13 +498,13 @@ fn spawn_raw(opts: task_opts, +f: fn~()) unsafe {
|
||||
|
||||
option::may(opts.notify_chan) {|c|
|
||||
// FIXME (1087): Would like to do notification in Rust
|
||||
rustrt::rust_task_config_notify(task_id, c);
|
||||
rustrt::rust_task_config_notify(new_task, c);
|
||||
}
|
||||
|
||||
rustrt::start_task(task_id, closure);
|
||||
rustrt::start_task(new_task, closure);
|
||||
unsafe::leak(f);
|
||||
|
||||
fn new_task_in_new_sched(opts: sched_opts) -> task_id {
|
||||
fn new_task_in_new_sched(opts: sched_opts) -> *rust_task {
|
||||
if opts.native_stack_size != none {
|
||||
fail "native_stack_size scheduler option unimplemented";
|
||||
}
|
||||
@ -543,13 +543,13 @@ native mod rustrt {
|
||||
fn get_task_id() -> task_id;
|
||||
fn rust_get_task() -> *rust_task;
|
||||
|
||||
fn new_task() -> task_id;
|
||||
fn rust_new_task_in_sched(id: sched_id) -> task_id;
|
||||
fn new_task() -> *rust_task;
|
||||
fn rust_new_task_in_sched(id: sched_id) -> *rust_task;
|
||||
|
||||
fn rust_task_config_notify(
|
||||
id: task_id, &&chan: comm::chan<notification>);
|
||||
task: *rust_task, &&chan: comm::chan<notification>);
|
||||
|
||||
fn start_task(id: task_id, closure: *rust_closure);
|
||||
fn start_task(task: *rust_task, closure: *rust_closure);
|
||||
|
||||
fn rust_task_is_unwinding(rt: *rust_task) -> bool;
|
||||
fn unsupervise();
|
||||
|
@ -81,9 +81,7 @@ rust_start(uintptr_t main_fn, int argc, char **argv, void* crate_map) {
|
||||
rust_kernel *kernel = new rust_kernel(srv);
|
||||
rust_sched_id sched_id = kernel->create_scheduler(env->num_sched_threads);
|
||||
rust_scheduler *sched = kernel->get_scheduler_by_id(sched_id);
|
||||
rust_task_id root_id = sched->create_task(NULL, "main", MAIN_STACK_SIZE);
|
||||
rust_task *root_task = kernel->get_task_by_id(root_id);
|
||||
I(kernel, root_task != NULL);
|
||||
rust_task *root_task = sched->create_task(NULL, "main", MAIN_STACK_SIZE);
|
||||
rust_task_thread *thread = root_task->thread;
|
||||
command_line_args *args
|
||||
= new (kernel, "main command line args")
|
||||
@ -96,7 +94,6 @@ rust_start(uintptr_t main_fn, int argc, char **argv, void* crate_map) {
|
||||
}
|
||||
|
||||
root_task->start((spawn_fn)main_fn, NULL, args->args);
|
||||
root_task->deref();
|
||||
root_task = NULL;
|
||||
|
||||
int ret = kernel->wait_for_schedulers();
|
||||
|
@ -424,18 +424,18 @@ get_task_id() {
|
||||
return task->id;
|
||||
}
|
||||
|
||||
static rust_task_id
|
||||
static rust_task*
|
||||
new_task_common(rust_scheduler *sched, rust_task *parent) {
|
||||
return sched->create_task(parent, NULL);
|
||||
}
|
||||
|
||||
extern "C" CDECL rust_task_id
|
||||
extern "C" CDECL rust_task*
|
||||
new_task() {
|
||||
rust_task *task = rust_task_thread::get_task();
|
||||
return new_task_common(task->sched, task);
|
||||
}
|
||||
|
||||
extern "C" CDECL rust_task_id
|
||||
extern "C" CDECL rust_task*
|
||||
rust_new_task_in_sched(rust_sched_id id) {
|
||||
rust_task *task = rust_task_thread::get_task();
|
||||
rust_scheduler *sched = task->kernel->get_scheduler_by_id(id);
|
||||
@ -444,13 +444,8 @@ rust_new_task_in_sched(rust_sched_id id) {
|
||||
}
|
||||
|
||||
extern "C" CDECL void
|
||||
rust_task_config_notify(rust_task_id task_id, chan_handle *chan) {
|
||||
rust_task *task = rust_task_thread::get_task();
|
||||
rust_task *target = task->kernel->get_task_by_id(task_id);
|
||||
A(task->thread, target != NULL,
|
||||
"This function should only be called when we know the task exists");
|
||||
rust_task_config_notify(rust_task *target, chan_handle *chan) {
|
||||
target->config_notify(*chan);
|
||||
target->deref();
|
||||
}
|
||||
|
||||
extern "C" rust_task *
|
||||
@ -459,11 +454,8 @@ rust_get_task() {
|
||||
}
|
||||
|
||||
extern "C" CDECL void
|
||||
start_task(rust_task_id id, fn_env_pair *f) {
|
||||
rust_task *task = rust_task_thread::get_task();
|
||||
rust_task *target = task->kernel->get_task_by_id(id);
|
||||
start_task(rust_task *target, fn_env_pair *f) {
|
||||
target->start(f->f, f->env, NULL);
|
||||
target->deref();
|
||||
}
|
||||
|
||||
extern "C" CDECL int
|
||||
|
@ -82,7 +82,7 @@ rust_scheduler::kill_all_tasks() {
|
||||
}
|
||||
}
|
||||
|
||||
rust_task_id
|
||||
rust_task *
|
||||
rust_scheduler::create_task(rust_task *spawner, const char *name,
|
||||
size_t init_stack_sz) {
|
||||
size_t thread_no;
|
||||
@ -95,7 +95,7 @@ rust_scheduler::create_task(rust_task *spawner, const char *name,
|
||||
return thread->create_task(spawner, name, init_stack_sz);
|
||||
}
|
||||
|
||||
rust_task_id
|
||||
rust_task *
|
||||
rust_scheduler::create_task(rust_task *spawner, const char *name) {
|
||||
return create_task(spawner, name, env->min_stack_size);
|
||||
}
|
||||
|
@ -39,10 +39,10 @@ public:
|
||||
void start_task_threads();
|
||||
void join_task_threads();
|
||||
void kill_all_tasks();
|
||||
rust_task_id create_task(rust_task *spawner,
|
||||
const char *name,
|
||||
size_t init_stack_sz);
|
||||
rust_task_id create_task(rust_task *spawner, const char *name);
|
||||
rust_task* create_task(rust_task *spawner,
|
||||
const char *name,
|
||||
size_t init_stack_sz);
|
||||
rust_task* create_task(rust_task *spawner, const char *name);
|
||||
|
||||
void release_task();
|
||||
|
||||
|
@ -159,8 +159,6 @@ void
|
||||
rust_task_thread::release_task(rust_task *task) {
|
||||
// Nobody should have a ref to the task at this point
|
||||
I(this, task->get_ref_count() == 0);
|
||||
// Kernel should not know about the task any more
|
||||
I(this, kernel->get_task_by_id(task->id) == NULL);
|
||||
// Now delete the task, which will require using this thread's
|
||||
// memory region.
|
||||
delete task;
|
||||
@ -304,7 +302,7 @@ rust_task_thread::get_cache() {
|
||||
return &cache;
|
||||
}
|
||||
|
||||
rust_task_id
|
||||
rust_task *
|
||||
rust_task_thread::create_task(rust_task *spawner, const char *name,
|
||||
size_t init_stack_sz) {
|
||||
rust_task *task =
|
||||
@ -319,7 +317,7 @@ rust_task_thread::create_task(rust_task *spawner, const char *name,
|
||||
}
|
||||
|
||||
kernel->register_task(task);
|
||||
return task->id;
|
||||
return task;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -120,8 +120,8 @@ public:
|
||||
|
||||
void kill_all_tasks();
|
||||
|
||||
rust_task_id create_task(rust_task *spawner, const char *name,
|
||||
size_t init_stack_sz);
|
||||
rust_task *create_task(rust_task *spawner, const char *name,
|
||||
size_t init_stack_sz);
|
||||
|
||||
void transition(rust_task *task,
|
||||
rust_task_list *src, rust_task_list *dst,
|
||||
|
Loading…
Reference in New Issue
Block a user