Skip to content

Commit

Permalink
Change from 'spawner' to 'supervisor' in rust_task, and add an unsupe…
Browse files Browse the repository at this point in the history
…rvise call.
  • Loading branch information
graydon committed Jul 5, 2010
1 parent 3175c83 commit b1eeb9b
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 6 deletions.
1 change: 1 addition & 0 deletions src/lib/sys.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,6 @@ native "rust" mod rustrt {
fn align_of[T]() -> uint;
fn refcount[T](@T t) -> uint;
fn gc();
fn unsupervise();
}

5 changes: 5 additions & 0 deletions src/rt/rust_builtin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,11 @@ gc(rust_task *task) {
task->gc(1);
}

extern "C" CDECL void
unsupervise(rust_task *task) {
task->unsupervise();
}

extern "C" CDECL rust_vec*
vec_alloc(rust_task *task, type_desc *t, size_t n_elts)
{
Expand Down
5 changes: 4 additions & 1 deletion src/rt/rust_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -625,7 +625,7 @@ rust_task : public rc_base<rust_task>,
ptr_vec<rust_task> *state;
rust_cond *cond;
uintptr_t* dptr; // Rendezvous pointer for send/recv.
rust_task *spawner; // Parent-link.
rust_task *supervisor; // Parent-link for failure propagation.
size_t idx;
size_t gc_alloc_thresh;
size_t gc_alloc_accum;
Expand Down Expand Up @@ -685,6 +685,9 @@ rust_task : public rc_base<rust_task>,
// Run the gc glue on the task stack.
void gc(size_t nargs);

// Disconnect from our supervisor.
void unsupervise();

// Notify tasks waiting for us that we are about to die.
void notify_waiting_tasks();

Expand Down
19 changes: 14 additions & 5 deletions src/rt/rust_task.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ rust_task::rust_task(rust_dom *dom, rust_task *spawner) :
state(&dom->running_tasks),
cond(NULL),
dptr(0),
spawner(spawner),
supervisor(spawner),
idx(0),
waiting_tasks(dom),
alarm(this)
Expand Down Expand Up @@ -336,12 +336,12 @@ rust_task::fail(size_t nargs) {
if (this == dom->root_task)
dom->fail();
run_after_return(nargs, dom->root_crate->get_unwind_glue());
if (spawner) {
if (supervisor) {
dom->log(rust_log::TASK,
"task 0x%" PRIxPTR
" propagating failure to parent 0x%" PRIxPTR,
this, spawner);
spawner->kill();
" propagating failure to supervisor 0x%" PRIxPTR,
this, supervisor);
supervisor->kill();
}
}

Expand All @@ -353,6 +353,15 @@ rust_task::gc(size_t nargs)
run_after_return(nargs, dom->root_crate->get_gc_glue());
}

void
rust_task::unsupervise()
{
dom->log(rust_log::TASK,
"task 0x%" PRIxPTR " disconnecting from supervisor 0x%" PRIxPTR,
this, supervisor);
supervisor = NULL;
}

void
rust_task::notify_waiting_tasks()
{
Expand Down

0 comments on commit b1eeb9b

Please sign in to comment.