Skip to content

Commit 42e4342

Browse files
committed
Change executionStateChangedCallback to be synchronous
There was no need for this function to be `async` and it’s easier to reason about the code if there are no suspensions here.
1 parent 6aaf23f commit 42e4342

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

Sources/SKCore/TaskScheduler.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -179,12 +179,12 @@ public actor QueuedTask<TaskDescription: TaskDescriptionProtocol> {
179179

180180
/// A callback that will be called when the task starts executing, is cancelled to be rescheduled, or when it finishes
181181
/// execution.
182-
private let executionStateChangedCallback: (@Sendable (QueuedTask, TaskExecutionState) async -> Void)?
182+
private let executionStateChangedCallback: (@Sendable (QueuedTask, TaskExecutionState) -> Void)?
183183

184184
init(
185185
priority: TaskPriority,
186186
description: TaskDescription,
187-
executionStateChangedCallback: (@Sendable (QueuedTask, TaskExecutionState) async -> Void)?
187+
executionStateChangedCallback: (@Sendable (QueuedTask, TaskExecutionState) -> Void)?
188188
) async {
189189
self._priority = AtomicUInt8(initialValue: priority.rawValue)
190190
self.description = description
@@ -238,7 +238,7 @@ public actor QueuedTask<TaskDescription: TaskDescriptionProtocol> {
238238
executionTask = task
239239
executionTaskCreatedContinuation.yield(task)
240240
_isExecuting.value = true
241-
await executionStateChangedCallback?(self, .executing)
241+
executionStateChangedCallback?(self, .executing)
242242
return await task.value
243243
}
244244

@@ -247,11 +247,11 @@ public actor QueuedTask<TaskDescription: TaskDescriptionProtocol> {
247247
self.executionTask = nil
248248
_isExecuting.value = false
249249
if Task.isCancelled && self.cancelledToBeRescheduled {
250-
await executionStateChangedCallback?(self, .cancelledToBeRescheduled)
250+
executionStateChangedCallback?(self, .cancelledToBeRescheduled)
251251
self.cancelledToBeRescheduled = false
252252
return ExecutionTaskFinishStatus.cancelledToBeRescheduled
253253
} else {
254-
await executionStateChangedCallback?(self, .finished)
254+
executionStateChangedCallback?(self, .finished)
255255
return ExecutionTaskFinishStatus.terminated
256256
}
257257
}
@@ -352,7 +352,7 @@ public actor TaskScheduler<TaskDescription: TaskDescriptionProtocol> {
352352
priority: TaskPriority? = nil,
353353
_ taskDescription: TaskDescription,
354354
@_inheritActorContext executionStateChangedCallback: (
355-
@Sendable (QueuedTask<TaskDescription>, TaskExecutionState) async -> Void
355+
@Sendable (QueuedTask<TaskDescription>, TaskExecutionState) -> Void
356356
)? = nil
357357
) async -> QueuedTask<TaskDescription> {
358358
let queuedTask = await QueuedTask(

Tests/SourceKitLSPTests/MainFilesProviderTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ final class MainFilesProviderTests: XCTestCase {
212212
DidChangeWatchedFilesNotification(changes: [FileEvent(uri: fancyLibraryUri, type: .changed)])
213213
)
214214

215-
// 'MyFancyLibrary.c' now also includes 'shared.h'. Since it lexicographically preceeds MyLibrary, we should use its
215+
// 'MyFancyLibrary.c' now also includes 'shared.h'. Since it lexicographically precedes MyLibrary, we should use its
216216
// build settings.
217217
let postEditDiags = try await project.testClient.nextDiagnosticsNotification()
218218
XCTAssertEqual(postEditDiags.diagnostics.count, 1)

0 commit comments

Comments
 (0)