Skip to content

Instantly share code, notes, and snippets.

View Creanomy's full-sized avatar

Creanomy Creanomy

View GitHub Profile
@danielgalasko
danielgalasko / RepeatingTimer.swift
Last active March 28, 2024 10:26
A repeating GCD timer that can run on a background queue
/// RepeatingTimer mimics the API of DispatchSourceTimer but in a way that prevents
/// crashes that occur from calling resume multiple times on a timer that is
/// already resumed (noted by https://github.com/SiftScience/sift-ios/issues/52
class RepeatingTimer {
let timeInterval: TimeInterval
init(timeInterval: TimeInterval) {
self.timeInterval = timeInterval
}