Skip to content

Commit 6ae9af3

Browse files
committed
Add @sendable to blocks
1 parent 29fb5b2 commit 6ae9af3

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

Tool/Sources/DebounceFunction/ThrottleFunction.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ public actor ThrottleFunction<T> {
88
var lastFinishTime: Date = .init(timeIntervalSince1970: 0)
99
var now: () -> Date = { Date() }
1010

11-
public init(duration: TimeInterval, block: @escaping (T) async -> Void) {
11+
public init(duration: TimeInterval, block: @escaping @Sendable (T) async -> Void) {
1212
self.duration = duration
1313
self.block = block
1414
}
@@ -50,13 +50,13 @@ public actor ThrottleRunner {
5050
self.duration = duration
5151
}
5252

53-
public func throttle(block: @escaping () async -> Void) {
53+
public func throttle(block: @escaping @Sendable () async -> Void) {
5454
if task == nil {
5555
scheduleTask(wait: now().timeIntervalSince(lastFinishTime) < duration, block: block)
5656
}
5757
}
5858

59-
func scheduleTask(wait: Bool, block: @escaping () async -> Void) {
59+
func scheduleTask(wait: Bool, block: @escaping @Sendable () async -> Void) {
6060
task = Task.detached { [weak self] in
6161
guard let self else { return }
6262
do {

0 commit comments

Comments
 (0)