]> gitweb.factorcode.org Git - factor.git/commitdiff
core-foundation.timers: allow interval to be specified in the constructor.
authorJohn Benediktsson <mrjbq7@gmail.com>
Wed, 19 Oct 2011 22:30:55 +0000 (15:30 -0700)
committerJohn Benediktsson <mrjbq7@gmail.com>
Wed, 19 Oct 2011 22:30:55 +0000 (15:30 -0700)
basis/core-foundation/run-loop/run-loop.factor
basis/core-foundation/timers/timers.factor

index b4465c2975f07c18f747df3536069caf74777bb4..ee7e88502155f8b4800ac1df2494f69ce73a7f3d 100644 (file)
@@ -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
index 99091408bbb8fbdcdb2196f93cb4a567882acaa2..adf4e8a1c617aacaef8c9ad850b77fd659b512fe 100644 (file)
@@ -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
+) ;
+
+