perf(efficiency): 落实首批采样减负与发行包瘦身
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
import Foundation
|
||||
|
||||
/// Missing capabilities back off independently; success in another zone cannot reset this state.
|
||||
nonisolated struct SensorSchedule {
|
||||
private(set) var deadline: TimeInterval = 0
|
||||
private var failures = 0
|
||||
|
||||
func isDue(at now: TimeInterval) -> Bool { now >= deadline }
|
||||
|
||||
mutating func complete(available: Bool, at now: TimeInterval) {
|
||||
failures = available ? 0 : min(failures + 1, 5)
|
||||
deadline = now + (available ? 10 : min(600, 60 * pow(2, Double(failures - 1))))
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user