[ 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
! 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
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
CFRunLoopTimerRef timer,
CFAbsoluteTime fireDate
) ;
+
+FUNCTION: Boolean CFRunLoopTimerDoesRepeat (
+ CFRunLoopTimerRef timer
+) ;
+
+FUNCTION: CFTimeInterval CFRunLoopTimerGetInterval (
+ CFRunLoopTimerRef timer
+) ;
+
+FUNCTION: CFAbsoluteTime CFRunLoopTimerGetNextFireDate (
+ CFRunLoopTimerRef timer
+) ;
+
+