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

SCM Repository

[smlnj] Annotation of /sml/trunk/src/eXene/lib/protocol/xshutdown.sml
ViewVC logotype

Annotation of /sml/trunk/src/eXene/lib/protocol/xshutdown.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 704 - (view) (download)

1 : monnier 2 (* xshutdown.sml
2 :     *
3 :     * COPYRIGHT (c) 1990,1991 by John H. Reppy. See COPYRIGHT file for details.
4 :     *
5 :     * This is the shutdown server for eXene. Log open connections and close them on
6 :     * shutdown.
7 :     *)
8 :    
9 :     structure XShutdown : sig
10 :    
11 :     val logConnection : XIo.connection -> unit
12 :     val unlogConnection : XIo.connection -> unit
13 :    
14 :     end = struct
15 :     local
16 :     datatype req
17 :     = LogConn of XIo.connection
18 :     | UnlogConn of XIo.connection
19 :     | Shutdown
20 :    
21 :     val reqCh : req CML.chan = CML.channel()
22 :     val replyCh : unit CML.chan = CML.channel()
23 :    
24 :     fun startServer () = let
25 :     fun loop conns = (case (CML.recv reqCh)
26 :     of LogConn arg => loop (arg::conns)
27 :     | UnlogConn conn => let
28 :     fun remove [] = []
29 :     | remove (c :: r) =
30 :     if XIo.sameConn(c, conn) then r else (c :: (remove r))
31 :     in
32 :     loop (remove conns)
33 :     end
34 :     | Shutdown => (
35 : jhr 704 let val tid = CML.getTid() in
36 :     TraceCML.trace(XDebug.libTM, fn () => [CML.tidToString tid, " ***** shutdown *****\n"])
37 :     end;
38 : monnier 2 app XIo.closeConn conns;
39 :     CML.send(replyCh, ())))
40 :     in
41 :     CML.spawn (fn () => loop []); ()
42 :     end
43 :    
44 :     fun shutdown () = (CML.send(reqCh, Shutdown); CML.recv replyCh)
45 :    
46 :     val _ = RunCML.logChannel("eXene-shutdown:reqCh", reqCh)
47 :     val _ = RunCML.logChannel("eXene-shutdown:replyCh", replyCh)
48 :     val _ = RunCML.logServer("eXene-shutdown", startServer, shutdown)
49 :    
50 :     in
51 :    
52 :     fun logConnection arg = CML.send(reqCh, LogConn arg)
53 :     fun unlogConnection sock = CML.send(reqCh, UnlogConn sock)
54 :    
55 :     end (* local *)
56 :     end (* XShutdown *)

root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0