! Copyright (C) 2006, 2008 Slava Pestov
! See http://factorcode.org/license.txt for BSD license.
-USING: alien.syntax destructors accessors kernel ;
+USING: alien.syntax destructors accessors kernel calendar ;
IN: core-foundation
TYPEDEF: void* CFTypeRef
: |CFRelease ( alien -- alien )
dup f CFRelease-destructor boa |dispose drop ; inline
+
+: >CFTimeInterval ( duration -- interval )
+ duration>seconds ; inline
+
+: >CFAbsoluteTime ( timestamp -- time )
+ T{ timestamp { year 2001 } { month 1 } { day 1 } } time-
+ duration>seconds ; inline
! Copyright (C) 2008 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
-USING: alien.syntax system math kernel core-foundation ;
+USING: alien.syntax system math kernel core-foundation calendar ;
IN: core-foundation.timers
TYPEDEF: void* CFRunLoopTimerRef
) ;
: <CFTimer> ( callback -- timer )
- [ f millis 1000 /f 60 0 0 ] dip f CFRunLoopTimerCreate ;
+ [ f now >CFAbsoluteTime 60 0 0 ] dip f CFRunLoopTimerCreate ;
FUNCTION: void CFRunLoopTimerInvalidate (
CFRunLoopTimerRef timer
) ;
+FUNCTION: Boolean CFRunLoopTimerIsValid (
+ CFRunLoopTimerRef timer
+) ;
+
FUNCTION: void CFRunLoopTimerSetNextFireDate (
CFRunLoopTimerRef timer,
CFAbsoluteTime fireDate