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

SCM Repository

[smlnj] Annotation of /sml/trunk/src/eXene/lib/protocol/xtime.sml
ViewVC logotype

Annotation of /sml/trunk/src/eXene/lib/protocol/xtime.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2 - (view) (download)

1 : monnier 2 (* xtime.sml
2 :     *
3 :     * COPYRIGHT (c) 1995 AT&T Bell Laboratories.
4 :     *
5 :     * An abstract interface to server time values.
6 :     *)
7 :    
8 :     structure XTime : sig
9 :    
10 :     datatype time = XT of Word32.word
11 :    
12 :     val toReal : time -> real
13 :    
14 :     val + : (time * time) -> time
15 :     val - : (time * time) -> time
16 :    
17 :     val < : (time * time) -> bool
18 :     val <= : (time * time) -> bool
19 :     val > : (time * time) -> bool
20 :     val >= : (time * time) -> bool
21 :    
22 :     end = struct
23 :    
24 :     (* X time values are 32-bit values in milliseconds since the server was booted
25 :     * and they wrap around every 49.7 days.
26 :     *)
27 :     datatype time = XT of Word32.word
28 :    
29 :     fun binOp rator (XT t1, XT t2) = XT(rator(t1, t2))
30 :     fun cmpOp rator (XT t1, XT t2) = rator(t1, t2)
31 :    
32 :     (** NOTE: the following works for small time values, but not for big ones!! **)
33 :     fun toReal (XT w) = Real.fromInt(Word32.toInt w)
34 :    
35 :     val (op +) = binOp Word32.+
36 :     val (op -) = binOp Word32.-
37 :    
38 :     val (op <) = cmpOp Word32.<
39 :     val (op <=) = cmpOp Word32.<=
40 :     val (op >) = cmpOp Word32.>
41 :     val (op >=) = cmpOp Word32.>=
42 :    
43 :     end (* XTime *)
44 :    

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