summaryrefslogtreecommitdiff
path: root/tests/spawn.ur
diff options
context:
space:
mode:
authorGravatar Adam Chlipala <adamc@hcoop.net>2009-04-04 14:55:36 -0400
committerGravatar Adam Chlipala <adamc@hcoop.net>2009-04-04 14:55:36 -0400
commitca7196c5dd362ccc6f19aaafef5b4252522e96a2 (patch)
treebd8687846d60efcadac3d2e06f77bdabedbec0b5 /tests/spawn.ur
parentdfe722a61e5c81cdfa6ed844933a14783cd9bd9c (diff)
spawn
Diffstat (limited to 'tests/spawn.ur')
-rw-r--r--tests/spawn.ur24
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/spawn.ur b/tests/spawn.ur
new file mode 100644
index 00000000..263b52bc
--- /dev/null
+++ b/tests/spawn.ur
@@ -0,0 +1,24 @@
+table t : {A : int, Ch : channel string}
+
+fun listener n ch =
+ s <- recv ch;
+ alert (show n ^ ": " ^ s);
+ listener n ch
+
+fun speak id msg =
+ r <- oneRow (SELECT t.Ch FROM t WHERE t.A = {[id]});
+ send r.T.Ch msg
+
+fun main () : transaction page =
+ ch1 <- channel;
+ dml (INSERT INTO t (A, Ch) VALUES (1, {[ch1]}));
+ ch2 <- channel;
+ dml (INSERT INTO t (A, Ch) VALUES (2, {[ch2]}));
+
+ s1 <- source "";
+ s2 <- source "";
+
+ return <xml><body onload={spawn (listener 1 ch1); spawn (listener 2 ch2)}>
+ 1: <ctextbox source={s1}/><button onclick={msg <- get s1; speak 1 msg}/><br/>
+ 2: <ctextbox source={s2}/><button onclick={msg <- get s2; speak 2 msg}/>
+ </body></xml>