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

SCM Repository

[smlnj] Diff of /sml/trunk/src/cml/src/core-cml/cleanup.sml
ViewVC logotype

Diff of /sml/trunk/src/cml/src/core-cml/cleanup.sml

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 7, Sun Jan 18 00:59:30 1998 UTC revision 8, Sun Jan 18 01:01:29 1998 UTC
# Line 10  Line 10 
10    
11      val clean : when -> unit      val clean : when -> unit
12    
     val startServers    : unit -> unit  
     val shutdownServers : unit -> unit  
   
13      val exportFnCleanup : unit -> unit      val exportFnCleanup : unit -> unit
14    
15    end = struct    end = struct
# Line 80  Line 77 
77                    CML.joinEvt(CML.spawnc f when),                    CML.joinEvt(CML.spawnc f when),
78                    CML.timeOutEvt(Time.fromSeconds 1)                    CML.timeOutEvt(Time.fromSeconds 1)
79                  ]                  ]
80    (*DEBUG*
81    fun doCleaner (tag, _, f) = (
82    Debug.sayDebugTS(concat["do Cleaner \"", tag, "\"\n"]);
83    CML.select [
84    CML.wrap(CML.joinEvt(CML.spawnc f when), fn _ => Debug.sayDebugTS "  done\n"),
85    CML.wrap(CML.timeOutEvt(Time.fromSeconds 1), fn _ => Debug.sayDebugTS "  timeout\n")
86    ])
87    *DEBUG*)
88            in            in
89            (* remove uneccesary clean-up routines *)            (* remove uneccesary clean-up routines *)
90              case when              case when
# Line 142  Line 147 
147              l := f(!l)              l := f(!l)
148            end            end
149    
150      fun appInit l () = List.app (fn ITEM{init, ...} => init()) (List.rev (!l))      fun appInit l = List.app (fn ITEM{init, ...} => init()) (List.rev (!l))
151    
152      fun unlogAll () = (chanList := []; mboxList := []; serverList := [])      fun unlogAll () = (chanList := []; mboxList := []; serverList := [])
153    
# Line 171  Line 176 
176            serverList := ITEM{key=name, init=f, shut=g} :: (!serverList))            serverList := ITEM{key=name, init=f, shut=g} :: (!serverList))
177      val logServer = protect logServer      val logServer = protect logServer
178    
179      val startServers = appInit serverList      fun startServers () = appInit serverList
180    
181      fun shutdownServers () = let      fun shutdownServers () = let
182            fun shut (ITEM{key, shut, ...}) = CML.select [            fun shut (ITEM{key, shut, ...}) = CML.select [
# Line 182  Line 187 
187              app shut (!serverList)              app shut (!serverList)
188            end            end
189    
190        fun cleanServers (AtInit | AtInitFn) = startServers()
191          | cleanServers (AtShutdown | AtExit) = shutdownServers()
192    
193    (* clean the logged channels and mailboxes. *)    (* clean the logged channels and mailboxes. *)
194      fun cleanChannels _ = (appInit chanList (); appInit mboxList ())      fun cleanChannels _ = (appInit chanList; appInit mboxList)
195    
196      val _ = addCleaner ("Channels&Mailboxes", [AtInit,AtShutdown], cleanChannels)    (* Add the standard cleaners *)
197        val _ = (
198              addCleaner ("Channels&Mailboxes", [AtInit,AtShutdown], cleanChannels);
199              addCleaner ("Servers", atAll, cleanServers))
200    
201    (* remove useless cleaners and clear the channel/mailbox logs    (* remove useless cleaners and clear the channel/mailbox logs
202     * prior to exporting a stand-alone CML program.     * prior to exporting a stand-alone CML program.

Legend:
Removed from v.7  
changed lines
  Added in v.8

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