Migrate atomic call sites to Synchronization.Atomic and ThreadSafeBox

Replace AtomicBool/UInt8/UInt32/Int32 from
ToolsProtocolsSwiftExtensions with Synchronization.Atomic<T> where
the storage is a static, module-level let, or class stored property.
For local lets captured by @Sendable closures (where Atomic's
~Copyable nature prevents capture), use ThreadSafeBox<T> instead.
This commit is contained in:
Rintaro Ishizaki
2026-05-21 10:58:34 -07:00
parent f4117f68c1
commit 83de30d29f
12 changed files with 59 additions and 38 deletions
@@ -19,6 +19,7 @@ public import Foundation
public import SKOptions
package import SourceKitLSP
import SwiftExtensions
import Synchronization
import TSCExtensions
package import ToolchainRegistry
@_spi(SourceKitLSP) import ToolsProtocolsSwiftExtensions
@@ -29,7 +30,7 @@ import struct TSCBasic.AbsolutePath
public final class InProcessSourceKitLSPClient: Sendable {
private let server: SourceKitLSPServer
private let nextRequestID = AtomicUInt32(initialValue: 0)
private let nextRequestID = Atomic<UInt32>(0)
public convenience init(
toolchainPath: URL?,
@@ -123,7 +124,9 @@ public final class InProcessSourceKitLSPClient: Sendable {
_ request: R,
reply: @Sendable @escaping (LSPResult<R.Response>) -> Void
) -> RequestID {
let requestID = RequestID.string("sk-\(Int(nextRequestID.fetchAndIncrement()))")
let requestID = RequestID.string(
"sk-\(Int(nextRequestID.wrappingAdd(1, ordering: .sequentiallyConsistent).oldValue))"
)
server.handle(request, id: requestID, reply: reply)
return requestID
}