Home My Page Projects Code Snippets Project Openings SML/NJ
Summary Activity Forums Tracker Lists Tasks Docs Surveys News SCM Files

SCM Repository

[smlnj] View of /sml/trunk/src/cml/cml-lib/simple-rpc.sml
ViewVC logotype

View of /sml/trunk/src/cml/cml-lib/simple-rpc.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 844 - (download) (annotate)
Wed Jun 20 20:39:15 2001 UTC (18 years, 2 months ago) by blume
File size: 1437 byte(s)
CML compiles and works again
(* 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