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