diff options
Diffstat (limited to 'src/libcore/task/spawn.rs')
| -rw-r--r-- | src/libcore/task/spawn.rs | 49 |
1 files changed, 25 insertions, 24 deletions
diff --git a/src/libcore/task/spawn.rs b/src/libcore/task/spawn.rs index 0e1284da3bc..6eaace1fa1a 100644 --- a/src/libcore/task/spawn.rs +++ b/src/libcore/task/spawn.rs @@ -61,6 +61,7 @@ ****************************************************************************/ #[doc(hidden)]; // FIXME #3538 +#[warn(deprecated_mode)]; use rt::rust_task; use rt::rust_closure; @@ -69,16 +70,16 @@ macro_rules! move_it ( { $x:expr } => { unsafe { let y <- *ptr::addr_of(&($x)); move y } } ) -pub type TaskSet = send_map::linear::LinearMap<*rust_task,()>; +type TaskSet = send_map::linear::LinearMap<*rust_task,()>; -pub fn new_taskset() -> TaskSet { +fn new_taskset() -> TaskSet { send_map::linear::LinearMap() } -pub fn taskset_insert(tasks: &mut TaskSet, task: *rust_task) { +fn taskset_insert(tasks: &mut TaskSet, task: *rust_task) { let didnt_overwrite = tasks.insert(task, ()); assert didnt_overwrite; } -pub fn taskset_remove(tasks: &mut TaskSet, task: *rust_task) { +fn taskset_remove(tasks: &mut TaskSet, task: *rust_task) { let was_present = tasks.remove(&task); assert was_present; } @@ -87,7 +88,7 @@ pub fn taskset_each(tasks: &TaskSet, blk: fn(v: *rust_task) -> bool) { } // One of these per group of linked-failure tasks. -pub type TaskGroupData = { +type TaskGroupData = { // All tasks which might kill this group. When this is empty, the group // can be "GC"ed (i.e., its link in the ancestor list can be removed). mut members: TaskSet, @@ -95,12 +96,12 @@ pub type TaskGroupData = { // tasks in this group. mut descendants: TaskSet, }; -pub type TaskGroupArc = private::Exclusive<Option<TaskGroupData>>; +type TaskGroupArc = private::Exclusive<Option<TaskGroupData>>; -pub type TaskGroupInner = &mut Option<TaskGroupData>; +type TaskGroupInner = &mut Option<TaskGroupData>; // A taskgroup is 'dead' when nothing can cause it to fail; only members can. -pub pure fn taskgroup_is_dead(tg: &TaskGroupData) -> bool { +pure fn taskgroup_is_dead(tg: &TaskGroupData) -> bool { (&tg.members).is_empty() } @@ -111,7 +112,7 @@ pub pure fn taskgroup_is_dead(tg: &TaskGroupData) -> bool { // taskgroup which was spawned-unlinked. Tasks from intermediate generations // have references to the middle of the list; when intermediate generations // die, their node in the list will be collected at a descendant's spawn-time. -pub type AncestorNode = { +type AncestorNode = { // Since the ancestor list is recursive, we end up with references to // exclusives within other exclusives. This is dangerous business (if // circular references arise, deadlock and memory leaks are imminent). @@ -124,16 +125,16 @@ pub type AncestorNode = { // Recursive rest of the list. mut ancestors: AncestorList, }; -pub enum AncestorList = Option<private::Exclusive<AncestorNode>>; +enum AncestorList = Option<private::Exclusive<AncestorNode>>; // Accessors for taskgroup arcs and ancestor arcs that wrap the unsafety. #[inline(always)] -pub fn access_group<U>(x: &TaskGroupArc, blk: fn(TaskGroupInner) -> U) -> U { +fn access_group<U>(x: &TaskGroupArc, blk: fn(TaskGroupInner) -> U) -> U { unsafe { x.with(blk) } } #[inline(always)] -pub fn access_ancestors<U>(x: &private::Exclusive<AncestorNode>, +fn access_ancestors<U>(x: &private::Exclusive<AncestorNode>, blk: fn(x: &mut AncestorNode) -> U) -> U { unsafe { x.with(blk) } } @@ -146,7 +147,7 @@ pub fn access_ancestors<U>(x: &private::Exclusive<AncestorNode>, // (3) As a bonus, coalesces away all 'dead' taskgroup nodes in the list. // FIXME(#2190): Change Option<fn@(...)> to Option<fn&(...)>, to save on // allocations. Once that bug is fixed, changing the sigil should suffice. -pub fn each_ancestor(list: &mut AncestorList, +fn each_ancestor(list: &mut AncestorList, bail_opt: Option<fn@(TaskGroupInner)>, forward_blk: fn(TaskGroupInner) -> bool) -> bool { @@ -271,7 +272,7 @@ pub fn each_ancestor(list: &mut AncestorList, } // One of these per task. -pub struct TCB { +struct TCB { me: *rust_task, // List of tasks with whose fates this one's is intertwined. tasks: TaskGroupArc, // 'none' means the group has failed. @@ -303,7 +304,7 @@ pub struct TCB { } } -pub fn TCB(me: *rust_task, tasks: TaskGroupArc, ancestors: AncestorList, +fn TCB(me: *rust_task, tasks: TaskGroupArc, ancestors: AncestorList, is_main: bool, notifier: Option<AutoNotify>) -> TCB { let notifier = move notifier; @@ -318,7 +319,7 @@ pub fn TCB(me: *rust_task, tasks: TaskGroupArc, ancestors: AncestorList, } } -pub struct AutoNotify { +struct AutoNotify { notify_chan: Chan<Notification>, mut failed: bool, drop { @@ -327,14 +328,14 @@ pub struct AutoNotify { } } -pub fn AutoNotify(chan: Chan<Notification>) -> AutoNotify { +fn AutoNotify(chan: Chan<Notification>) -> AutoNotify { AutoNotify { notify_chan: chan, failed: true // Un-set above when taskgroup successfully made. } } -pub fn enlist_in_taskgroup(state: TaskGroupInner, me: *rust_task, +fn enlist_in_taskgroup(state: TaskGroupInner, me: *rust_task, is_member: bool) -> bool { let newstate = util::replace(state, None); // If 'None', the group was failing. Can't enlist. @@ -350,7 +351,7 @@ pub fn enlist_in_taskgroup(state: TaskGroupInner, me: *rust_task, } // NB: Runs in destructor/post-exit context. Can't 'fail'. -pub fn leave_taskgroup(state: TaskGroupInner, me: *rust_task, +fn leave_taskgroup(state: TaskGroupInner, me: *rust_task, is_member: bool) { let newstate = util::replace(state, None); // If 'None', already failing and we've already gotten a kill signal. @@ -363,7 +364,7 @@ pub fn leave_taskgroup(state: TaskGroupInner, me: *rust_task, } // NB: Runs in destructor/post-exit context. Can't 'fail'. -pub fn kill_taskgroup(state: TaskGroupInner, me: *rust_task, is_main: bool) { +fn kill_taskgroup(state: TaskGroupInner, me: *rust_task, is_main: bool) { // NB: We could do the killing iteration outside of the group arc, by // having "let mut newstate" here, swapping inside, and iterating after. // But that would let other exiting tasks fall-through and exit while we @@ -405,7 +406,7 @@ macro_rules! taskgroup_key ( () => (cast::transmute((-2 as uint, 0u))) ) -pub fn gen_child_taskgroup(linked: bool, supervised: bool) +fn gen_child_taskgroup(linked: bool, supervised: bool) -> (TaskGroupArc, AncestorList, bool) { let spawner = rt::rust_get_task(); /*######################################################################* @@ -487,7 +488,7 @@ pub fn gen_child_taskgroup(linked: bool, supervised: bool) } } -pub fn spawn_raw(opts: TaskOpts, +f: fn~()) { +pub fn spawn_raw(opts: TaskOpts, f: fn~()) { let (child_tg, ancestors, is_main) = gen_child_taskgroup(opts.linked, opts.supervised); @@ -532,7 +533,7 @@ pub fn spawn_raw(opts: TaskOpts, +f: fn~()) { fn make_child_wrapper(child: *rust_task, child_arc: TaskGroupArc, ancestors: AncestorList, is_main: bool, notify_chan: Option<Chan<Notification>>, - +f: fn~()) -> fn~() { + f: fn~()) -> fn~() { let child_data = ~mut Some((move child_arc, move ancestors)); return fn~(move notify_chan, move child_data, move f) { // Agh. Get move-mode items into the closure. FIXME (#2829) @@ -636,7 +637,7 @@ pub fn spawn_raw(opts: TaskOpts, +f: fn~()) { #[test] fn test_spawn_raw_simple() { let po = comm::Port(); - let ch = comm::Chan(po); + let ch = comm::Chan(&po); do spawn_raw(default_task_opts()) { comm::send(ch, ()); } |
