-
-
Save avesus/4472901c77f19b5e26d0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dispatch_queue_t gcdTimerQueue; | |
dispatch_source_t gcdTimer; | |
gcdTimer = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, gcdTimerQueue); | |
if (gcdTimer) { | |
uint64_t seconds = 30ull; | |
uint64_t interval = seconds * NSEC_PER_SEC; | |
uint64_t leeway = 1ull * NSEC_PER_SEC; | |
__block typeof(self) _self = self; | |
dispatch_source_set_timer(gcdTimer, dispatch_walltime(NULL, 0), interval, leeway); | |
dispatch_source_set_event_handler(gcdTimer, ^{ | |
// stuff to run on a periodic basis | |
}); | |
dispatch_resume(gcdTimer); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment