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 ;
|
[ 2drop reset-run-loop yield ] alien-callback ;
|
||||||
|
|
||||||
: init-thread-timer ( -- )
|
: 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? )
|
: run-one-iteration ( nanos -- handled? )
|
||||||
reset-run-loop
|
reset-run-loop
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
! Copyright (C) 2008, 2010 Slava Pestov.
|
! Copyright (C) 2008, 2010 Slava Pestov.
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
USING: alien.c-types alien.syntax system math kernel calendar
|
USING: alien.c-types alien.syntax calendar core-foundation
|
||||||
core-foundation core-foundation.time calendar.unix ;
|
core-foundation.time calendar.unix kernel locals math system ;
|
||||||
IN: core-foundation.timers
|
IN: core-foundation.timers
|
||||||
|
|
||||||
TYPEDEF: void* CFRunLoopTimerRef
|
TYPEDEF: void* CFRunLoopTimerRef
|
||||||
|
|
@ -18,8 +18,9 @@ FUNCTION: CFRunLoopTimerRef CFRunLoopTimerCreate (
|
||||||
CFRunLoopTimerContext* context
|
CFRunLoopTimerContext* context
|
||||||
) ;
|
) ;
|
||||||
|
|
||||||
: <CFTimer> ( callback -- timer )
|
:: <CFTimer> ( interval callback -- timer )
|
||||||
[ f system-micros >CFAbsoluteTime 60 0 0 ] dip f CFRunLoopTimerCreate ;
|
f system-micros >CFAbsoluteTime interval 0 0 callback f
|
||||||
|
CFRunLoopTimerCreate ;
|
||||||
|
|
||||||
FUNCTION: void CFRunLoopTimerInvalidate (
|
FUNCTION: void CFRunLoopTimerInvalidate (
|
||||||
CFRunLoopTimerRef timer
|
CFRunLoopTimerRef timer
|
||||||
|
|
@ -33,3 +34,17 @@ FUNCTION: void CFRunLoopTimerSetNextFireDate (
|
||||||
CFRunLoopTimerRef timer,
|
CFRunLoopTimerRef timer,
|
||||||
CFAbsoluteTime fireDate
|
CFAbsoluteTime fireDate
|
||||||
) ;
|
) ;
|
||||||
|
|
||||||
|
FUNCTION: Boolean CFRunLoopTimerDoesRepeat (
|
||||||
|
CFRunLoopTimerRef timer
|
||||||
|
) ;
|
||||||
|
|
||||||
|
FUNCTION: CFTimeInterval CFRunLoopTimerGetInterval (
|
||||||
|
CFRunLoopTimerRef timer
|
||||||
|
) ;
|
||||||
|
|
||||||
|
FUNCTION: CFAbsoluteTime CFRunLoopTimerGetNextFireDate (
|
||||||
|
CFRunLoopTimerRef timer
|
||||||
|
) ;
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue