diff options
Diffstat (limited to 'src/components/main/util/task.rs')
-rw-r--r-- | src/components/main/util/task.rs | 22 |
1 files changed, 8 insertions, 14 deletions
diff --git a/src/components/main/util/task.rs b/src/components/main/util/task.rs index 0300fa59200..f85688f7d2f 100644 --- a/src/components/main/util/task.rs +++ b/src/components/main/util/task.rs @@ -2,26 +2,20 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -use std::cell::Cell; -use std::comm; -use std::comm::{Chan, Port}; -use std::task; - -pub fn spawn_listener<A: Send>(f: ~fn(Port<A>)) -> Chan<A> { - let (setup_po, setup_ch) = comm::stream(); - do task::spawn { - let (po, ch) = comm::stream(); +pub fn spawn_listener<A: Send>(f: proc(Port<A>)) -> Chan<A> { + let (setup_po, setup_ch) = Chan::new(); + spawn(proc() { + let (po, ch) = Chan::new(); setup_ch.send(ch); f(po); - } + }); setup_po.recv() } -pub fn spawn_conversation<A: Send, B: Send>(f: ~fn(Port<A>, Chan<B>)) -> (Port<B>, Chan<A>) { - let (from_child, to_parent) = comm::stream(); - let to_parent = Cell::new(to_parent); +pub fn spawn_conversation<A: Send, B: Send>(f: proc(Port<A>, Chan<B>)) -> (Port<B>, Chan<A>) { + let (from_child, to_parent) = Chan::new(); let to_child = do spawn_listener |from_parent| { - f(from_parent, to_parent.take()) + f(from_parent, to_parent) }; (from_child, to_child) } |