Dans mon application iOS, j'utilise GCD comme minuteur exécuté sur un thread d'arrière-plan. Voici mon code:Quand la minuterie est-elle déclenchée
dispatch_source_t timer = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0));
double interval = 1.0;
dispatch_time_t startTime = dispatch_time(DISPATCH_TIME_NOW, 0);
uint64_t intervalTime = (int64_t)(interval * NSEC_PER_SEC);
dispatch_source_set_timer(timer, startTime, intervalTime, 0);
dispatch_source_set_event_handler(timer, ^{
// some code
});
// start timer
dispatch_resume(timer);
Je me demande quand le code à l'intérieur du bloc est appelé. Il est appelé chaque seconde (il peut arriver qu'il soit appelé même si l'appel précédent n'est pas encore terminé) ou il est appelé après une seconde à la fin de l'appel précédent?