aboutsummaryrefslogtreecommitdiffstats
path: root/src/servo-net/util.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/servo-net/util.rs')
-rw-r--r--src/servo-net/util.rs15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/servo-net/util.rs b/src/servo-net/util.rs
new file mode 100644
index 00000000000..ec1aea92e86
--- /dev/null
+++ b/src/servo-net/util.rs
@@ -0,0 +1,15 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * 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 core::comm::{Chan, Port};
+
+pub fn spawn_listener<A: Owned>(f: ~fn(Port<A>)) -> Chan<A> {
+ let (setup_po, setup_ch) = comm::stream();
+ do task::spawn {
+ let (po, ch) = comm::stream();
+ setup_ch.send(ch);
+ f(po);
+ }
+ setup_po.recv()
+}