Skip to content

Commit

Permalink
preconcurrency linux
Browse files Browse the repository at this point in the history
  • Loading branch information
glbrntt committed Aug 15, 2023
1 parent 59a9c7d commit bdd24e2
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Sources/GRPC/ConnectionManagerChannelProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ internal struct DefaultChannelProvider: ConnectionManagerChannelProvider, Sendab
@usableFromInline
internal var errorDelegate: Optional<ClientErrorDelegate>
@usableFromInline
internal var debugChannelInitializer: Optional< @Sendable (Channel) -> EventLoopFuture < Void>>
internal var debugChannelInitializer: Optional<@Sendable (Channel) -> EventLoopFuture <Void>>

@inlinable
internal init(
Expand Down
4 changes: 4 additions & 0 deletions Tests/GRPCTests/CapturingLogHandler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#if os(Linux)
@preconcurrency import struct Foundation.Date
#else
import struct Foundation.Date
#endif
import class Foundation.DateFormatter
import Logging
import NIOConcurrencyHelpers
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -346,19 +346,22 @@ private final class EmbeddedEventLoopGroup: EventLoopGroup, Sendable {
return EventLoopIterator(self.loops)
}

internal func shutdownGracefully(queue: DispatchQueue, _ callback: @escaping (Error?) -> Void) {
var shutdownError: Error?
internal func shutdownGracefully(
queue: DispatchQueue,
_ callback: @escaping @Sendable (Error?) -> Void
) {
let lockedError = NIOLockedValueBox<Error?>(nil)

for loop in self.loops {
loop.shutdownGracefully(queue: queue) { error in
if let error = error {
shutdownError = error
lockedError.withLockedValue { $0 = error }
}
}
}

queue.sync {
callback(shutdownError)
callback(lockedError.withLockedValue { $0 })
}
}
}

0 comments on commit bdd24e2

Please sign in to comment.