@@ -52,16 +52,16 @@ fileprivate struct NotificationTimeoutError: Error, CustomStringConvertible {
5252/// We can't use an `AsyncStream` for this because an `AsyncStream` is cancelled if a task that calls
5353/// `AsyncStream.Iterator.next` is cancelled and we want to be able to wait for new notifications even if waiting for a
5454/// a previous notification timed out.
55- actor PendingNotifications {
56- private var values : [ any NotificationType ] = [ ]
55+ final class PendingNotifications : Sendable {
56+ private let values = ThreadSafeBox < [ any NotificationType ] > ( initialValue : [ ] )
5757
58- func add( _ value: any NotificationType ) {
59- values. insert ( value, at: 0 )
58+ nonisolated func add( _ value: any NotificationType ) {
59+ values. value . insert ( value, at: 0 )
6060 }
6161
6262 func next( timeout: Duration , pollingInterval: Duration = . milliseconds( 10 ) ) async throws -> any NotificationType {
6363 for _ in 0 ..< Int ( timeout. seconds / pollingInterval. seconds) {
64- if let value = values. popLast ( ) {
64+ if let value = values. value . popLast ( ) {
6565 return value
6666 }
6767 try await Task . sleep ( for: pollingInterval)
@@ -358,9 +358,7 @@ package final class TestSourceKitLSPClient: MessageHandler, Sendable {
358358
359359 /// - Important: Implementation detail of `TestSourceKitLSPServer`. Do not call from tests.
360360 package func handle( _ notification: some NotificationType ) {
361- Task {
362- await notifications. add ( notification)
363- }
361+ notifications. add ( notification)
364362 }
365363
366364 /// - Important: Implementation detail of `TestSourceKitLSPClient`. Do not call from tests.
0 commit comments