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/cm/concur/unix-servers.sml
ViewVC logotype

Diff of /sml/trunk/src/cm/concur/unix-servers.sml

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

revision 631, Fri Apr 28 08:30:52 2000 UTC revision 632, Sat Apr 29 15:50:42 2000 UTC
# Line 40  Line 40 
40      val someIdle = ref (Concur.pcond ())      val someIdle = ref (Concur.pcond ())
41    
42      local      local
         val nservers = ref 0  
43          val all = ref (IntMap.empty: server IntMap.map)          val all = ref (IntMap.empty: server IntMap.map)
44            fun nservers () = IntMap.numItems (!all)
45      in      in
46          fun noServers () = !nservers = 0          fun allIdle () = length (!idle) = nservers ()
47            fun noServers () = nservers () = 0
48          fun allServers () = IntMap.listItems (!all)          fun allServers () = IntMap.listItems (!all)
49          fun addServer s = let          fun addServer s = let
50              val ns = !nservers              val ns = nservers ()
51          in          in
             nservers := ns + 1;  
52              all := IntMap.insert (!all, servId s, s)              all := IntMap.insert (!all, servId s, s)
53          end          end
54          fun delServer s = let          fun delServer s =
55              val ns = !nservers - 1              (all := #1 (IntMap.remove (!all, servId s));
         in  
             all := #1 (IntMap.remove (!all, servId s));  
             nservers := ns;  
56              (* If this was the last server we need to wake up              (* If this was the last server we need to wake up
57               * everyone who is currently waiting to grab a server.               * everyone who is currently waiting to grab a server.
58               * The "grab"-loop will then gracefully fail and               * The "grab"-loop will then gracefully fail and
59               * not cause a deadlock. *)               * not cause a deadlock. *)
60              if ns = 0 then               if noServers () then
61                  (Say.dsay ["No more servers -> back to sequential mode.\n"];                  (Say.dsay ["No more servers -> back to sequential mode.\n"];
62                   Concur.signal (!someIdle))                   Concur.signal (!someIdle))
63              else ()               else ())
         end  
64      end      end
65    
66      (* This really shouldn't be here, but putting it into SrcPath would      (* This really shouldn't be here, but putting it into SrcPath would
# Line 321  Line 317 
317               ignore (wait_status (s, false)))               ignore (wait_status (s, false)))
318      in      in
319          startAll st          startAll st
320        end
321    
322        fun cmb_new { archos } = let
323            fun st s =
324                (send (s, concat ["cmb ", archos, "\n"]);
325                 ignore (wait_status (s, false)))
326        in
327            startAll st
328      end      end
329    
330      fun dirbase db = let      fun dirbase db = let

Legend:
Removed from v.631  
changed lines
  Added in v.632

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