// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 or the MIT license // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. // Just a named container for our op, so it can have impls pub struct NominalOp { op: T } impl NominalOp: Clone { fn clone(&self) -> NominalOp { copy *self } } pub fn spawn_listener( +f: fn~(oldcomm::Port)) -> oldcomm::Chan { let setup_po = oldcomm::Port(); let setup_ch = oldcomm::Chan(&setup_po); do task::spawn |move f| { let po = oldcomm::Port(); let ch = oldcomm::Chan(&po); oldcomm::send(setup_ch, ch); f(move po); } oldcomm::recv(setup_po) } pub fn spawn_conversation (+f: fn~(oldcomm::Port, oldcomm::Chan)) -> (oldcomm::Port, oldcomm::Chan) { let from_child = oldcomm::Port(); let to_parent = oldcomm::Chan(&from_child); let to_child = do spawn_listener |move f, from_parent| { f(from_parent, to_parent) }; (from_child, to_child) }