comparison clock.ur @ 10:0337f88f2efc

Clock
author Adam Chlipala <adam@chlipala.net>
date Fri, 22 Jul 2011 15:40:03 -0400
parents
children ccd0a169e827
comparison
equal deleted inserted replaced
9:1e04008eaef7 10:0337f88f2efc
1 (** Reactive view of the current time *)
2
3 type t = { Source : source time,
4 Period : int }
5
6 fun create ms =
7 tm <- now;
8 t <- source tm;
9 return {Source = t, Period = ms}
10
11 fun start t =
12 let
13 fun loop () =
14 sleep t.Period;
15 tm <- now;
16 set t.Source tm;
17 loop ()
18 in
19 spawn (loop ())
20 end
21
22 fun signal t = Basis.signal t.Source