mirror of
https://github.com/Ranchero-Software/NetNewsWire.git
synced 2025-02-10 00:50:55 +01:00
Add logging to PostponingBlock.
This commit is contained in:
parent
a8f952b710
commit
96fefbc800
@ -6,6 +6,7 @@
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import os
|
||||
|
||||
/// Runs a block of code in the future. Each time `runInFuture` is called, the block is postponed again until the future by `delayInterval`.
|
||||
@MainActor public final class PostponingBlock {
|
||||
@ -15,6 +16,8 @@ import Foundation
|
||||
private let name: String // For debugging
|
||||
private var timer: Timer?
|
||||
|
||||
private let logger = Logger(subsystem: Bundle.main.bundleIdentifier!, category: "PostponingBlock")
|
||||
|
||||
public init(delayInterval: TimeInterval, name: String, block: @escaping () -> Void) {
|
||||
|
||||
self.delayInterval = delayInterval
|
||||
@ -47,6 +50,7 @@ private extension PostponingBlock {
|
||||
|
||||
if let timer, timer.isValid {
|
||||
timer.invalidate()
|
||||
logger.info("Canceling existing timer in PostponingBlock: \(self.name)")
|
||||
}
|
||||
timer = nil
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user