remove >duration word and instead make a private >nanoseconds word in alarms

db4
Doug Coleman 2009-11-21 18:01:25 -06:00
parent f6ff09cc72
commit 97288b8a04
2 changed files with 6 additions and 9 deletions

View File

@ -19,13 +19,15 @@ SYMBOL: alarm-thread
: notify-alarm-thread ( -- )
alarm-thread get-global interrupt ;
: normalize-argument ( obj -- nanoseconds )
>duration duration>nanoseconds >integer ;
GENERIC: >nanoseconds ( obj -- duration/f )
M: f >nanoseconds ;
M: real >nanoseconds >integer ;
M: duration >nanoseconds duration>nanoseconds >integer ;
: <alarm> ( quot start interval -- alarm )
alarm new
swap dup [ normalize-argument ] when >>interval
swap dup [ normalize-argument nano-count + ] when >>start
swap >nanoseconds >>interval
swap >nanoseconds nano-count + >>start
swap >>quot
<box> >>entry ;

View File

@ -170,11 +170,6 @@ M: timestamp easter ( timestamp -- timestamp )
: microseconds ( x -- duration ) 1000000 / seconds ;
: nanoseconds ( x -- duration ) 1000000000 / seconds ;
GENERIC: >duration ( obj -- duration/f )
M: duration >duration ;
M: real >duration seconds ;
M: f >duration ;
GENERIC: year ( obj -- n )
M: integer year ;
M: timestamp year year>> ;