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/branches/SMLNJ/src/smlnj-lib/Reactive/machine.sml
ViewVC logotype

Diff of /sml/branches/SMLNJ/src/smlnj-lib/Reactive/machine.sml

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

revision 3, Sat Oct 4 23:33:46 1997 UTC revision 8, Sun Jan 18 01:01:29 1998 UTC
# Line 69  Line 69 
69      val stop : unit -> code      val stop : unit -> code
70      val suspend : unit -> code      val suspend : unit -> code
71      val action : (machine -> unit) -> code      val action : (machine -> unit) -> code
72      val exec   : {      val exec   : (machine -> {stop : unit -> unit, done : unit -> bool}) -> code
             start : machine -> unit,  
             stop  : machine -> unit,  
             done  : machine -> bool  
           } -> code  
73      val ifThenElse : ((machine -> bool) * code * code) -> code      val ifThenElse : ((machine -> bool) * code * code) -> code
74      val repeat     : (int * code) -> code      val repeat     : (int * code) -> code
75      val loop       : code -> code      val loop       : code -> code
# Line 261  Line 257 
257                }                }
258            end            end
259    
260      fun exec {start, stop, done} = let      fun exec f = let
261            val termFlg = ref false            val termFlg = ref false
262            val running = ref false            val ops = ref(NONE : {stop : unit -> unit, done : unit -> bool} option)
263  (** NOTE: what if a reset occurs while we are running?  We would need to change  (** NOTE: what if a reset occurs while we are running?  We would need to change
264   ** the type of resetMeth to take a machine parameter.   ** the type of resetMeth to take a machine parameter.
265   **)   **)
266            fun resetMeth () = (termFlg := false)            fun resetMeth () = (termFlg := false)
267            fun preemptMeth m = if !running then (running := false; stop m) else ()            fun preemptMeth m = (case !ops
268            fun activationMeth m = if !running                   of NONE => ()
269                  then if done m                    | SOME{stop, ...} => (ops := NONE; stop())
270                    then (running := false; TERM)                  (* end case *))
271              fun activationMeth m = (case !ops
272                     of SOME{done, ...} => if done ()
273                          then (ops := NONE; TERM)
274                    else STOP                    else STOP
275                  else (running := true; start m; SUSP)                    | NONE => (ops := SOME(f m); SUSP)
276                    (* end case *))
277            in            in
278              C{  isTerm          = isTermMeth termFlg,              C{  isTerm          = isTermMeth termFlg,
279                  terminate       = terminateMeth termFlg,                  terminate       = terminateMeth termFlg,

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

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