     var maxDelay: TimeInterval
     let action: () -> Void
     private var scheduled = false
+    private var performing = false
     private var next = Date.distantPast
 
     init(maxDelay: TimeInterval, action: @escaping () -> Void) {

    func nowIfNeeded() {
        if scheduled { now() }
    }

}

    }

    @objc func now() {
        if performing { return }
        cancel()
        performing = true
        DispatchQueue.main.async {
            self.performing = false
            self.action()
            self.next = Date(timeIntervalSinceNow: self.maxDelay)
        }
    }

    func later() {
        if scheduled { return }
        if performing { return }
        let now = Date()
        if next < now {
            self.now()
