I have a CFRunLoopTimer
created in a C ++ class as shown below:
#import <CoreFoundation/CoreFoundation.h> void cClass::StartTimer() { if(!mActiveSenseTimer) { CFTimeInterval TIMER_INTERVAL = 5; CFRunLoopTimerContext TimerContext = {0, this, NULL, NULL, NULL}; CFAbsoluteTime FireTime = CFAbsoluteTimeGetCurrent() + TIMER_INTERVAL; mTimer = CFRunLoopTimerCreate(kCFAllocatorDefault, FireTime, 0, 0, 0, ActiveSenseTimerCallback, &TimerContext); NSLog(@"RunLoop:0x%x, TimerIsValid:%d, TimeIsNow:%f, TimerWillFireAt:%f", CFRunLoopGetCurrent(), CFRunLoopTimerIsValid(mActiveSenseTimer), CFAbsoluteTimeGetCurrent(), FireTime); } } void ActiveSenseTimerCallback(CFRunLoopTimerRef timer, void *info) { NSLog(@"Timeout"); CFRunLoopTimerContext TimerContext; TimerContext.version = 0; CFRunLoopTimerGetContext(timer, &TimerContext); ((cClass *)TimerContext.info)->Timeout(); }
Calling cClass::StartTimer()
results in the following log output:
RunLoop: 0x7655d60, TimerIsValid: 1, TimeIsNow: 389196910.537962, TimerWillFireAt: 389196915.537956
However, my timer never fires. Any ideas why?
source share