SCM Repository
View of /sml/trunk/src/cml/cml-lib/simple-rpc.sml
Parent Directory
|
Revision Log
Revision 290 -
(download)
(annotate)
Sat May 22 21:01:25 1999 UTC (21 years, 9 months ago) by monnier
File size: 1437 byte(s)
Sat May 22 21:01:25 1999 UTC (21 years, 9 months ago) by monnier
File size: 1437 byte(s)
This commit was generated by cvs2svn to compensate for changes in r289, which included commits to RCS files with non-trunk default branches.
(* simple-rpc.sml * * COPYRIGHT (c) 1997 AT&T Labs Research. * * Generators for simple RPC protocols. *) structure SimpleRPC : SIMPLE_RPC = struct type 'a event = 'a CML.event fun call reqMB arg = let val replV = SyncVar.iVar() in Mailbox.send(reqMb, (arg, replV)); SyncVar.iGet replV end fun mkRPC f = let val reqMb = Mailbox.mailbox() val entryEvt = CML.wrap ( Mailbox.recvEvt reqMb, fn (arg, replV) => SyncVar.iPut(replV, f arg)) in { call = call reqMB, entryEvt = entryEvt } end fun mkRPC_In f = let val reqMb = Mailbox.mailbox() val reqEvt = Mailbox.recvEvt reqMb fun entryEvt state = CML.wrap ( reqEvt, fn (arg, replV) => SyncVar.iPut(replV, f(arg, state))) in { call = call reqMB, entryEvt = entryEvt } end fun mkRPC_Out f = let val reqMb = Mailbox.mailbox() val reqEvt = Mailbox.recvEvt reqMb val entryEvt = CML.wrap ( reqEvt, fn (arg, replV) => let val (res, state') = f arg in SyncVar.iPut(replV, res); state' end) in { call = call reqMB, entryEvt = entryEvt } end fun mkRPC_InOut f = let val reqMb = Mailbox.mailbox() val reqEvt = Mailbox.recvEvt reqMb fun entryEvt state = CML.wrap ( reqEvt, fn (arg, replV) => let val (res, state') = f(arg, state) in SyncVar.iPut(replV, res); state' end) in { call = call reqMB, entryEvt = entryEvt } end end
root@smlnj-gforge.cs.uchicago.edu | ViewVC Help |
Powered by ViewVC 1.0.0 |