Skip to content

Commit 5812458

Browse files
committed
Manually order nonisolated(nonsending) relative to @escaping in public interfaces
1 parent 7bf2acf commit 5812458

File tree

4 files changed

+8
-8
lines changed

4 files changed

+8
-8
lines changed

Sources/LanguageServerProtocolTransport/JSONRPCConnection.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ public final class JSONRPCConnection: Connection {
286286
/// - Important: `start` must be called before sending any data over the `JSONRPCConnection`.
287287
public func start(
288288
receiveHandler: MessageHandler,
289-
closeHandler: @escaping @Sendable () async -> Void = {}
289+
closeHandler: nonisolated(nonsending) @escaping @Sendable () async -> Void = {}
290290
) {
291291
queue.sync {
292292
precondition(state == .created)

Sources/ToolsProtocolsSwiftExtensions/AsyncQueue.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ public final class AsyncQueue<TaskMetadata: DependencyTracker>: Sendable {
9393
public func async<Success: Sendable>(
9494
priority: TaskPriority? = nil,
9595
metadata: TaskMetadata,
96-
@_inheritActorContext operation: @escaping @Sendable () async -> Success
96+
@_inheritActorContext operation: nonisolated(nonsending) @escaping @Sendable () async -> Success
9797
) -> Task<Success, Never> {
9898
let throwingTask = asyncThrowing(priority: priority, metadata: metadata, operation: operation)
9999
return Task(priority: priority) {
@@ -114,7 +114,7 @@ public final class AsyncQueue<TaskMetadata: DependencyTracker>: Sendable {
114114
public func asyncThrowing<Success: Sendable>(
115115
priority: TaskPriority? = nil,
116116
metadata: TaskMetadata,
117-
@_inheritActorContext operation: @escaping @Sendable () async throws -> Success
117+
@_inheritActorContext operation: nonisolated(nonsending) @escaping @Sendable () async throws -> Success
118118
) -> Task<Success, any Error> {
119119
let id = UUID()
120120

@@ -178,7 +178,7 @@ extension AsyncQueue where TaskMetadata == Serial {
178178
@discardableResult
179179
public func async<Success: Sendable>(
180180
priority: TaskPriority? = nil,
181-
@_inheritActorContext operation: @escaping @Sendable () async -> Success
181+
@_inheritActorContext operation: nonisolated(nonsending) @escaping @Sendable () async -> Success
182182
) -> Task<Success, Never> {
183183
return self.async(priority: priority, metadata: Serial(), operation: operation)
184184
}
@@ -187,7 +187,7 @@ extension AsyncQueue where TaskMetadata == Serial {
187187
/// for serial queues that don't specify any metadata.
188188
public func asyncThrowing<Success: Sendable>(
189189
priority: TaskPriority? = nil,
190-
@_inheritActorContext operation: @escaping @Sendable () async throws -> Success
190+
@_inheritActorContext operation: nonisolated(nonsending) @escaping @Sendable () async throws -> Success
191191
) -> Task<Success, any Error> {
192192
return self.asyncThrowing(priority: priority, metadata: Serial(), operation: operation)
193193
}

Sources/ToolsProtocolsSwiftExtensions/AsyncUtils.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ extension Collection where Self: Sendable, Element: Sendable {
139139
/// Transforms all elements in the collection concurrently and returns the transformed collection.
140140
@_spi(SourceKitLSP) public func concurrentMap<TransformedElement: Sendable>(
141141
maxConcurrentTasks: Int = ProcessInfo.processInfo.activeProcessorCount,
142-
_ transform: @escaping @Sendable (Element) async -> TransformedElement
142+
_ transform: nonisolated(nonsending) @escaping @Sendable (Element) async -> TransformedElement
143143
) async -> [TransformedElement] {
144144
let indexedResults = await withTaskGroup(of: (index: Int, element: TransformedElement).self) { taskGroup in
145145
var indexedResults: [(index: Int, element: TransformedElement)] = []
@@ -170,7 +170,7 @@ extension Collection where Self: Sendable, Element: Sendable {
170170
}
171171

172172
/// Invoke `body` for every element in the collection and wait for all calls of `body` to finish
173-
@_spi(SourceKitLSP) public func concurrentForEach(_ body: @escaping @Sendable (Element) async -> Void) async {
173+
@_spi(SourceKitLSP) public func concurrentForEach(_ body: nonisolated(nonsending) @escaping @Sendable (Element) async -> Void) async {
174174
await withTaskGroup(of: Void.self) { taskGroup in
175175
for element in self {
176176
taskGroup.addTask {

Sources/ToolsProtocolsSwiftExtensions/Task+WithPriorityChangedHandler.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
@_spi(SourceKitLSP) public func withTaskPriorityChangedHandler<T: Sendable>(
2020
initialPriority: TaskPriority = Task.currentPriority,
2121
pollingInterval: Duration = .seconds(0.1),
22-
@_inheritActorContext operation: @escaping @Sendable () async throws -> T,
22+
@_inheritActorContext operation: nonisolated(nonsending) @escaping @Sendable () async throws -> T,
2323
taskPriorityChanged: @escaping @Sendable () -> Void
2424
) async throws -> T {
2525
let lastPriority = ThreadSafeBox(initialValue: initialPriority)

0 commit comments

Comments
 (0)