adamc@728: table channels : { Client : client, Channel : channel (string * int * float) }
adamc@728: PRIMARY KEY Client
adamc@728:
adamc@728: fun writeBack v =
adamc@728: me <- self;
adamc@728: r <- oneRow (SELECT channels.Channel FROM channels WHERE channels.Client = {[me]});
adamc@728: send r.Channels.Channel v
adamc@728:
adamc@728: fun main () =
adamc@728: me <- self;
adamc@728: ch <- channel;
adamc@728: dml (INSERT INTO channels (Client, Channel) VALUES ({[me]}, {[ch]}));
adamc@728:
adamc@728: buf <- Buffer.create;
adamc@728:
adamc@728: let
adamc@728: fun receiverA () =
adamc@728: v <- recv ch;
adamc@728: Buffer.write buf ("A:(" ^ v.1 ^ ", " ^ show v.2 ^ ", " ^ show v.3 ^ ")");
adamc@728: receiverA ()
adamc@728:
adamc@728: fun receiverB () =
adamc@728: v <- recv ch;
adamc@728: Buffer.write buf ("B:(" ^ v.1 ^ ", " ^ show v.2 ^ ", " ^ show v.3 ^ ")");
adamc@728: error Bail out!;
adamc@728: receiverB ()
adamc@728:
adamc@728: fun sender s n f =
adamc@729: sleep 2000;
adamc@728: writeBack (s, n, f);
adamc@728: sender (s ^ "!") (n + 1) (f + 1.23)
adamc@728: in
adamc@729: return alert ("Server error: " ^ s));
adamc@729: spawn (receiverA ()); spawn (receiverB ()); sender "" 0 0.0}>
adamc@728:
adamc@728:
adamc@728: end