Permalink
Browse files

core-foundation.timers: allow interval to be specified in the constru…

…ctor.
  • Loading branch information...
mrjbq7 committed Oct 19, 2011
1 parent b192227 commit 3d1155130c2e70cd0e85c0bca357c05760183cee
Showing with 20 additions and 5 deletions.
  1. +1 −1 basis/core-foundation/run-loop/run-loop.factor
  2. +19 −4 basis/core-foundation/timers/timers.factor
@@ -121,7 +121,7 @@ PRIVATE>
[ 2drop reset-run-loop yield ] alien-callback ;
: init-thread-timer ( -- )
- timer-callback <CFTimer> add-timer-to-run-loop ;
+ 60 timer-callback <CFTimer> add-timer-to-run-loop ;
: run-one-iteration ( nanos -- handled? )
reset-run-loop
@@ -1,7 +1,7 @@
! Copyright (C) 2008, 2010 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
-USING: alien.c-types alien.syntax system math kernel calendar
-core-foundation core-foundation.time calendar.unix ;
+USING: alien.c-types alien.syntax calendar core-foundation
+core-foundation.time calendar.unix kernel locals math system ;
IN: core-foundation.timers
TYPEDEF: void* CFRunLoopTimerRef
@@ -18,8 +18,9 @@ FUNCTION: CFRunLoopTimerRef CFRunLoopTimerCreate (
CFRunLoopTimerContext* context
) ;
-: <CFTimer> ( callback -- timer )
- [ f system-micros >CFAbsoluteTime 60 0 0 ] dip f CFRunLoopTimerCreate ;
+:: <CFTimer> ( interval callback -- timer )
+ f system-micros >CFAbsoluteTime interval 0 0 callback f
+ CFRunLoopTimerCreate ;
FUNCTION: void CFRunLoopTimerInvalidate (
CFRunLoopTimerRef timer
@@ -33,3 +34,17 @@ FUNCTION: void CFRunLoopTimerSetNextFireDate (
CFRunLoopTimerRef timer,
CFAbsoluteTime fireDate
) ;
+
+FUNCTION: Boolean CFRunLoopTimerDoesRepeat (
+ CFRunLoopTimerRef timer
+) ;
+
+FUNCTION: CFTimeInterval CFRunLoopTimerGetInterval (
+ CFRunLoopTimerRef timer
+) ;
+
+FUNCTION: CFAbsoluteTime CFRunLoopTimerGetNextFireDate (
+ CFRunLoopTimerRef timer
+) ;
+
+

0 comments on commit 3d11551

Please sign in to comment.