这是我们参加06年全国开源软件的竞赛作品

源代码在线查看: simple-rpc.sml

软件大小: 10488 K
上传用户: shsy22
关键词: 开源软件 竞赛
下载地址: 免注册下载 普通下载 VIP

相关代码

				(* 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							

相关资源