Skip to content

Commit b1eeb9b

Browse files
committed
Change from 'spawner' to 'supervisor' in rust_task, and add an unsupervise call.
1 parent 3175c83 commit b1eeb9b

File tree

4 files changed

+24
-6
lines changed

4 files changed

+24
-6
lines changed

src/lib/sys.rs

+1
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,6 @@ native "rust" mod rustrt {
1717
fn align_of[T]() -> uint;
1818
fn refcount[T](@T t) -> uint;
1919
fn gc();
20+
fn unsupervise();
2021
}
2122

src/rt/rust_builtin.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,11 @@ gc(rust_task *task) {
8686
task->gc(1);
8787
}
8888

89+
extern "C" CDECL void
90+
unsupervise(rust_task *task) {
91+
task->unsupervise();
92+
}
93+
8994
extern "C" CDECL rust_vec*
9095
vec_alloc(rust_task *task, type_desc *t, size_t n_elts)
9196
{

src/rt/rust_internal.h

+4-1
Original file line numberDiff line numberDiff line change
@@ -625,7 +625,7 @@ rust_task : public rc_base<rust_task>,
625625
ptr_vec<rust_task> *state;
626626
rust_cond *cond;
627627
uintptr_t* dptr; // Rendezvous pointer for send/recv.
628-
rust_task *spawner; // Parent-link.
628+
rust_task *supervisor; // Parent-link for failure propagation.
629629
size_t idx;
630630
size_t gc_alloc_thresh;
631631
size_t gc_alloc_accum;
@@ -685,6 +685,9 @@ rust_task : public rc_base<rust_task>,
685685
// Run the gc glue on the task stack.
686686
void gc(size_t nargs);
687687

688+
// Disconnect from our supervisor.
689+
void unsupervise();
690+
688691
// Notify tasks waiting for us that we are about to die.
689692
void notify_waiting_tasks();
690693

src/rt/rust_task.cpp

+14-5
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ rust_task::rust_task(rust_dom *dom, rust_task *spawner) :
6262
state(&dom->running_tasks),
6363
cond(NULL),
6464
dptr(0),
65-
spawner(spawner),
65+
supervisor(spawner),
6666
idx(0),
6767
waiting_tasks(dom),
6868
alarm(this)
@@ -336,12 +336,12 @@ rust_task::fail(size_t nargs) {
336336
if (this == dom->root_task)
337337
dom->fail();
338338
run_after_return(nargs, dom->root_crate->get_unwind_glue());
339-
if (spawner) {
339+
if (supervisor) {
340340
dom->log(rust_log::TASK,
341341
"task 0x%" PRIxPTR
342-
" propagating failure to parent 0x%" PRIxPTR,
343-
this, spawner);
344-
spawner->kill();
342+
" propagating failure to supervisor 0x%" PRIxPTR,
343+
this, supervisor);
344+
supervisor->kill();
345345
}
346346
}
347347

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

356+
void
357+
rust_task::unsupervise()
358+
{
359+
dom->log(rust_log::TASK,
360+
"task 0x%" PRIxPTR " disconnecting from supervisor 0x%" PRIxPTR,
361+
this, supervisor);
362+
supervisor = NULL;
363+
}
364+
356365
void
357366
rust_task::notify_waiting_tasks()
358367
{

0 commit comments

Comments
 (0)