c++ - Why is my CFRunLoopTimer not firing? -


i have cfrunlooptimer created within c++ class 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 following log output:

runloop:0x7655d60, timerisvalid:1, timeisnow:389196910.537962, timerwillfireat:389196915.537956

however, timer never fires. ideas why?

quote docs

a timer needs added run loop mode before fire. add timer run loop, use cfrunloopaddtimer. timer can registered 1 run loop @ time, although can in multiple modes within run loop.

also make sure run loop doesn't die before timer fires.


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -