diff --git a/syndicate-examples/timer-demo.rkt b/syndicate-examples/timer-demo.rkt index c30d769..cc6ac90 100644 --- a/syndicate-examples/timer-demo.rkt +++ b/syndicate-examples/timer-demo.rkt @@ -8,7 +8,7 @@ (standard-actor-system (ds) (at ds (log-info "waiting...") - (on (timeout 1000) + (on (timeout 1) (log-info "still waiting...")) - (stop-on (timeout 2000) + (stop-on (timeout 2) (log-info "done!"))))) diff --git a/syndicate/drivers/timer.rkt b/syndicate/drivers/timer.rkt index 931d13d..70b4f03 100644 --- a/syndicate/drivers/timer.rkt +++ b/syndicate/drivers/timer.rkt @@ -42,7 +42,7 @@ (heap-remove-min! heap) (hash-remove! timers label) (log-syndicate/drivers/timer-debug "expired timer ~a" label) - (turn! facet (lambda () (send! ds (TimerExpired label now)))) + (turn! facet (lambda () (send! ds (TimerExpired label (/ now 1000.0))))) (set! count-fired (+ count-fired 1)) (loop))))) (adjust-inhabitant-count! engine (- count-fired))) @@ -75,12 +75,12 @@ [(SetTimer label _ (TimerKind-clear)) (clear-timer! label) (loop)] - [(SetTimer label msecs (TimerKind-relative)) - (define deadline (+ (current-inexact-milliseconds) msecs)) + [(SetTimer label secs (TimerKind-relative)) + (define deadline (+ (current-inexact-milliseconds) (* 1000.0 secs))) (install-timer! label deadline) (loop)] [(SetTimer label deadline (TimerKind-absolute)) - (install-timer! label deadline) + (install-timer! label (* deadline 1000.0)) (loop)]))))))) (at ds @@ -88,19 +88,19 @@ (log-syndicate/drivers/timer-debug "received instruction ~a" instruction) (channel-put control-ch instruction)) - (during (Observe (:pattern (LaterThan ,(DLit $msecs))) _) + (during (Observe (:pattern (LaterThan ,(DLit $seconds))) _) (log-syndicate/drivers/timer-debug "observing (later-than ~a) at ~a" - msecs - (current-inexact-milliseconds)) + seconds + (/ (current-inexact-milliseconds) 1000.0)) (define timer-id (gensym 'timestate)) - (on-start (send! (SetTimer timer-id msecs (TimerKind-absolute)))) - (on-stop (send! (SetTimer timer-id msecs (TimerKind-clear)))) + (on-start (send! (SetTimer timer-id seconds (TimerKind-absolute)))) + (on-stop (send! (SetTimer timer-id seconds (TimerKind-clear)))) (on (message (TimerExpired timer-id _)) - (react (assert (LaterThan msecs))))))) + (react (assert (LaterThan seconds))))))) (define-event-expander timeout (syntax-rules () - [(_ [relative-msecs] body ...) + [(_ [relative-seconds] body ...) (let ((timer-id (gensym 'timeout))) - (on-start (send! (SetTimer timer-id relative-msecs (TimerKind-relative)))) + (on-start (send! (SetTimer timer-id relative-seconds (TimerKind-relative)))) (on (message (TimerExpired timer-id _)) body ...))])) diff --git a/syndicate/test/core/during-with-spawn.rkt b/syndicate/test/core/during-with-spawn.rkt index c8f7a92..dd44186 100644 --- a/syndicate/test/core/during-with-spawn.rkt +++ b/syndicate/test/core/during-with-spawn.rkt @@ -8,7 +8,7 @@ (standard-actor-system (ds) (spawn (at ds (assert 'item) - (on (timeout 50) (stop-current-facet)))) + (on (timeout 0.05) (stop-current-facet)))) (spawn #:daemon? #t (at ds (during/spawn 'item