Fix alarms bug

db4
Slava Pestov 2008-03-03 02:22:27 -06:00
parent dbd8ce49cf
commit e555c00287
2 changed files with 19 additions and 3 deletions

View File

@ -0,0 +1,17 @@
IN: alarms.tests
USING: alarms kernel calendar sequences tools.test threads
concurrency.count-downs ;
[ ] [
1 <count-down>
{ f } clone 2dup
[ first cancel-alarm count-down ] 2curry 1 seconds later
swap set-first
await
] unit-test
[ ] [
[
[ resume ] curry instant later drop
] "test" suspend drop
] unit-test

View File

@ -37,8 +37,8 @@ SYMBOL: alarm-thread
register-alarm ;
: call-alarm ( alarm -- )
dup alarm-quot try
dup alarm-entry box> drop
dup alarm-quot try
dup alarm-interval [ reschedule-alarm ] [ drop ] if ;
: (trigger-alarms) ( alarms now -- )
@ -46,8 +46,7 @@ SYMBOL: alarm-thread
2drop
] [
over heap-peek drop over alarm-expired? [
over heap-pop drop call-alarm
(trigger-alarms)
over heap-pop drop call-alarm (trigger-alarms)
] [
2drop
] if