Rename TCB to Taskgroup

This commit is contained in:
Ben Blum 2013-07-16 13:42:12 -04:00
parent f3c79c4026
commit 2183145850
2 changed files with 16 additions and 15 deletions

View File

@ -27,7 +27,7 @@ use super::local_heap::LocalHeap;
use rt::sched::{Scheduler, SchedHandle};
use rt::stack::{StackSegment, StackPool};
use rt::context::Context;
use task::spawn::TCB;
use task::spawn::Taskgroup;
use cell::Cell;
pub struct Task {
@ -37,7 +37,7 @@ pub struct Task {
logger: StdErrLogger,
unwinder: Unwinder,
home: Option<SchedHome>,
taskgroup: Option<TCB>,
taskgroup: Option<Taskgroup>,
death: Death,
destroyed: bool,
coroutine: Option<~Coroutine>

View File

@ -338,7 +338,7 @@ fn each_ancestor(list: &mut AncestorList,
}
// One of these per task.
pub struct TCB {
pub struct Taskgroup {
// List of tasks with whose fates this one's is intertwined.
tasks: TaskGroupArc, // 'none' means the group has failed.
// Lists of tasks who will kill us if they fail, but whom we won't kill.
@ -347,12 +347,12 @@ pub struct TCB {
notifier: Option<AutoNotify>,
}
impl Drop for TCB {
impl Drop for Taskgroup {
// Runs on task exit.
fn drop(&self) {
unsafe {
// FIXME(#4330) Need self by value to get mutability.
let this: &mut TCB = transmute(self);
let this: &mut Taskgroup = transmute(self);
// If we are failing, the whole taskgroup needs to die.
do RuntimeGlue::with_task_handle_and_failing |me, failing| {
@ -382,15 +382,15 @@ impl Drop for TCB {
}
}
pub fn TCB(tasks: TaskGroupArc,
pub fn Taskgroup(tasks: TaskGroupArc,
ancestors: AncestorList,
is_main: bool,
mut notifier: Option<AutoNotify>) -> TCB {
mut notifier: Option<AutoNotify>) -> Taskgroup {
for notifier.mut_iter().advance |x| {
x.failed = false;
}
TCB {
Taskgroup {
tasks: tasks,
ancestors: ancestors,
is_main: is_main,
@ -488,11 +488,11 @@ fn kill_taskgroup(state: TaskGroupInner, me: &TaskHandle, is_main: bool) {
// FIXME (#2912): Work around core-vs-coretest function duplication. Can't use
// a proper closure because the #[test]s won't understand. Have to fake it.
#[cfg(not(stage0))]
fn taskgroup_key() -> local_data::Key<@@mut TCB> {
fn taskgroup_key() -> local_data::Key<@@mut Taskgroup> {
unsafe { cast::transmute(-2) }
}
#[cfg(stage0)]
fn taskgroup_key() -> local_data::Key<@@mut TCB> {
fn taskgroup_key() -> local_data::Key<@@mut Taskgroup> {
unsafe { cast::transmute((-2, 0)) }
}
@ -540,7 +540,7 @@ impl RuntimeGlue {
}
}
fn with_my_taskgroup<U>(blk: &fn(&TCB) -> U) -> U {
fn with_my_taskgroup<U>(blk: &fn(&Taskgroup) -> U) -> U {
match context() {
OldTaskContext => unsafe {
let me = rt::rust_get_task();
@ -555,7 +555,8 @@ impl RuntimeGlue {
descendants: TaskSet::new(),
}));
// Main task/group has no ancestors, no notifier, etc.
let group = @@mut TCB(tasks, AncestorList(None), true, None);
let group = @@mut Taskgroup(tasks, AncestorList(None),
true, None);
local_set(OldHandle(me), taskgroup_key(), group);
blk(&**group)
}
@ -577,7 +578,7 @@ impl RuntimeGlue {
members: members,
descendants: TaskSet::new(),
}));
let group = TCB(tasks, AncestorList(None), true, None);
let group = Taskgroup(tasks, AncestorList(None), true, None);
(*me).taskgroup = Some(group);
(*me).taskgroup.get_ref()
}
@ -683,7 +684,7 @@ fn spawn_raw_newsched(mut opts: TaskOpts, f: ~fn()) {
if enlist_many(NewTask(handle), &child_tg, &mut ancestors) {
// Got in. We can run the provided child body, and can also run
// the taskgroup's exit-time-destructor afterward.
me.taskgroup = Some(TCB(child_tg, ancestors, is_main, None));
me.taskgroup = Some(Taskgroup(child_tg, ancestors, is_main, None));
true
} else {
false
@ -781,7 +782,7 @@ fn spawn_raw_oldsched(mut opts: TaskOpts, f: ~fn()) {
let notifier = notify_chan.map_consume(|c| AutoNotify(c));
if enlist_many(OldTask(child), &child_arc, &mut ancestors) {
let group = @@mut TCB(child_arc, ancestors, is_main, notifier);
let group = @@mut Taskgroup(child_arc, ancestors, is_main, notifier);
unsafe {
local_set(OldHandle(child), taskgroup_key(), group);
}