diff options
| author | Daniel Micay <danielmicay@gmail.com> | 2013-09-20 02:08:47 -0400 | 
|---|---|---|
| committer | Daniel Micay <danielmicay@gmail.com> | 2013-10-09 09:17:29 -0400 | 
| commit | 6a90e80b6240d8213f2b99fa470ef6ee04552d1b (patch) | |
| tree | e7ae38c849741fc9345652311dfa374f36b4be9a /src/libstd/task/spawn.rs | |
| parent | f647ccc79c38c1f80dbdb697900b2ba97e293263 (diff) | |
| download | rust-6a90e80b6240d8213f2b99fa470ef6ee04552d1b.tar.gz rust-6a90e80b6240d8213f2b99fa470ef6ee04552d1b.zip | |
option: rewrite the API to use composition
Diffstat (limited to 'src/libstd/task/spawn.rs')
| -rw-r--r-- | src/libstd/task/spawn.rs | 16 | 
1 files changed, 8 insertions, 8 deletions
| diff --git a/src/libstd/task/spawn.rs b/src/libstd/task/spawn.rs index a801bf3328d..d26f8eb1024 100644 --- a/src/libstd/task/spawn.rs +++ b/src/libstd/task/spawn.rs @@ -182,7 +182,7 @@ fn check_generation(_younger: uint, _older: uint) { } #[inline] #[cfg(test)] fn incr_generation(ancestors: &AncestorList) -> uint { - ancestors.map_default(0, |arc| access_ancestors(arc, |a| a.generation+1)) + ancestors.as_ref().map_default(0, |arc| access_ancestors(arc, |a| a.generation+1)) } #[inline] #[cfg(not(test))] fn incr_generation(_ancestors: &AncestorList) -> uint { 0 } @@ -243,7 +243,7 @@ fn each_ancestor(list: &mut AncestorList, // The map defaults to None, because if ancestors is None, we're at // the end of the list, which doesn't make sense to coalesce. - do ancestors.map_default((None,false)) |ancestor_arc| { + do ancestors.as_ref().map_default((None,false)) |ancestor_arc| { // NB: Takes a lock! (this ancestor node) do access_ancestors(ancestor_arc) |nobe| { // Argh, but we couldn't give it to coalesce() otherwise. @@ -386,7 +386,7 @@ fn enlist_in_taskgroup(state: TaskGroupInner, me: KillHandle, is_member: bool) -> bool { let me = Cell::new(me); // :( // If 'None', the group was failing. Can't enlist. - do state.map_mut_default(false) |group| { + do state.as_mut().map_default(false) |group| { (if is_member { &mut group.members } else { @@ -400,7 +400,7 @@ fn enlist_in_taskgroup(state: TaskGroupInner, me: KillHandle, fn leave_taskgroup(state: TaskGroupInner, me: &KillHandle, is_member: bool) { let me = Cell::new(me); // :( // If 'None', already failing and we've already gotten a kill signal. - do state.map_mut |group| { + do state.as_mut().map |group| { (if is_member { &mut group.members } else { @@ -414,7 +414,7 @@ fn kill_taskgroup(state: Option<TaskGroupData>, me: &KillHandle) { // Might already be None, if somebody is failing simultaneously. // That's ok; only one task needs to do the dirty work. (Might also // see 'None' if somebody already failed and we got a kill signal.) - do state.map_move |TaskGroupData { members: members, descendants: descendants }| { + do state.map |TaskGroupData { members: members, descendants: descendants }| { for sibling in members.move_iter() { // Skip self - killing ourself won't do much good. if &sibling != me { @@ -439,7 +439,7 @@ fn taskgroup_key() -> local_data::Key<@@mut Taskgroup> { struct RuntimeGlue; impl RuntimeGlue { fn kill_task(mut handle: KillHandle) { - do handle.kill().map_move |killed_task| { + do handle.kill().map |killed_task| { let killed_task = Cell::new(killed_task); do Local::borrow |sched: &mut Scheduler| { sched.enqueue_task(killed_task.take()); @@ -491,7 +491,7 @@ fn gen_child_taskgroup(linked: bool, supervised: bool) // with_my_taskgroup will lazily initialize the parent's taskgroup if // it doesn't yet exist. We don't want to call it in the unlinked case. do RuntimeGlue::with_my_taskgroup |spawner_group| { - let ancestors = AncestorList(spawner_group.ancestors.map(|x| x.clone())); + let ancestors = AncestorList(spawner_group.ancestors.as_ref().map(|x| x.clone())); if linked { // Child is in the same group as spawner. // Child's ancestors are spawner's ancestors. @@ -562,7 +562,7 @@ pub fn spawn_raw(mut opts: TaskOpts, f: ~fn()) { // Child task runs this code. // If child data is 'None', the enlist is vacuously successful. - let enlist_success = do child_data.take().map_move_default(true) |child_data| { + let enlist_success = do child_data.take().map_default(true) |child_data| { let child_data = Cell::new(child_data); // :( do Local::borrow |me: &mut Task| { let (child_tg, ancestors) = child_data.take(); | 
