@@ -10,16 +10,17 @@ public final class DispatchTimer: Sendable {
1010 public var nextDeadline : DispatchTime {
1111 _nextDeadline. access { $0 }
1212 }
13+
1314 private let _nextDeadline : Locked < DispatchTime >
1415
1516 public init (
1617 _ interval: DispatchTimeInterval ,
1718 repeat shouldRepeat: Bool = false ,
1819 block: @escaping @Sendable ( ) -> Void
1920 ) {
20- self . source = DispatchSource . makeTimerSource ( )
21+ source = DispatchSource . makeTimerSource ( )
2122 self . block = block
22- self . isRepeating = shouldRepeat
23+ isRepeating = shouldRepeat
2324
2425 let deadline = DispatchTime . now ( ) . advanced ( by: interval)
2526 _nextDeadline = Locked ( deadline)
@@ -46,9 +47,9 @@ public final class DispatchTimer: Sendable {
4647 fireAt deadline: DispatchTime ,
4748 block: @escaping @Sendable ( ) -> Void
4849 ) {
49- self . source = DispatchSource . makeTimerSource ( )
50+ source = DispatchSource . makeTimerSource ( )
5051 self . block = block
51- self . isRepeating = false
52+ isRepeating = false
5253 _nextDeadline = Locked ( deadline)
5354
5455 let interval = DispatchTime . now ( ) . distance ( to: deadline)
@@ -75,13 +76,13 @@ public final class DispatchTimer: Sendable {
7576private extension DispatchTimer {
7677 static func defaultTolerance( _ interval: DispatchTimeInterval ) -> DispatchTimeInterval {
7778 switch interval {
78- case . seconds( let amount) :
79+ case let . seconds( amount) :
7980 guard amount > 0 else { return . never }
8081 return . milliseconds( oneTenthOfOneThousand ( of: amount) )
81- case . milliseconds( let amount) :
82+ case let . milliseconds( amount) :
8283 guard amount > 0 else { return . never }
8384 return . microseconds( oneTenthOfOneThousand ( of: amount) )
84- case . microseconds( let amount) :
85+ case let . microseconds( amount) :
8586 guard amount > 0 else { return . never }
8687 return . nanoseconds( oneTenthOfOneThousand ( of: amount) )
8788 case . nanoseconds, . never:
@@ -98,5 +99,5 @@ private extension DispatchTimer {
9899}
99100
100101private func oneTenthOfOneThousand( of amount: Int ) -> Int {
101- return Int ( ( Double ( amount * 1000 ) * 0.1 ) . rounded ( ) )
102+ Int ( ( Double ( amount * 1000 ) * 0.1 ) . rounded ( ) )
102103}
0 commit comments