core-foundation.timers: allow interval to be specified in the constructor.
parent
b1922274e3
commit
3d1155130c
|
@ -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
|
||||
) ;
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue