Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 6 additions & 9 deletions Sources/NIOCore/AsyncChannel/AsyncChannel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//
// swift-format-ignore
// Note: Whitespace changes are used to workaround compiler bug
// Remove when compiler version 5.10 is no longer supported.
// https://github.com/swiftlang/swift/issues/79285

/// Wraps a NIO ``Channel`` object into a form suitable for use in Swift Concurrency.
///
Expand Down Expand Up @@ -331,11 +335,7 @@ public struct NIOAsyncChannel<Inbound: Sendable, Outbound: Sendable>: Sendable {
/// - Parameters:
/// - actor: actor where this function should be isolated to
/// - body: A closure that gets scoped access to the inbound and outbound.
public func executeThenClose<Result>(
isolation actor: isolated (any Actor)? = #isolation,
_ body: (_ inbound: NIOAsyncChannelInboundStream<Inbound>, _ outbound: NIOAsyncChannelOutboundWriter<Outbound>)
async throws -> sending Result
) async throws -> sending Result {
public func executeThenClose<Result>(isolation actor: isolated (any Actor)? = #isolation, _ body: (_ inbound: NIOAsyncChannelInboundStream<Inbound>, _ outbound: NIOAsyncChannelOutboundWriter<Outbound>) async throws -> sending Result) async throws -> sending Result {
let result: Result
do {
result = try await body(self._inbound, self._outbound)
Expand Down Expand Up @@ -427,10 +427,7 @@ extension NIOAsyncChannel {
/// - Parameters:
/// - actor: actor where this function should be isolated to
/// - body: A closure that gets scoped access to the inbound.
public func executeThenClose<Result>(
isolation actor: isolated (any Actor)? = #isolation,
_ body: (_ inbound: NIOAsyncChannelInboundStream<Inbound>) async throws -> sending Result
) async throws -> sending Result where Outbound == Never {
public func executeThenClose<Result>(isolation actor: isolated (any Actor)? = #isolation, _ body: (_ inbound: NIOAsyncChannelInboundStream<Inbound>) async throws -> sending Result) async throws -> sending Result where Outbound == Never {
let result: Result
do {
result = try await body(self._inbound)
Expand Down
10 changes: 5 additions & 5 deletions Sources/NIOCore/NIOLoopBound.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//
// swift-format-ignore
// Note: Whitespace changes are used to workaround compiler bug
// Remove when compiler version 5.10 is no longer supported.
// https://github.com/swiftlang/swift/issues/79285

/// ``NIOLoopBound`` is an always-`Sendable`, value-typed container allowing you access to ``value`` if and only if
/// you are accessing it on the right ``EventLoop``.
Expand Down Expand Up @@ -145,11 +149,7 @@ public final class NIOLoopBoundBox<Value>: @unchecked Sendable {
/// Contrary to ``init(_:eventLoop:)``, this method can be called off `eventLoop` because `value` is moved into the box and can no longer be accessed outside the box.
/// So we don't need to protect `value` itself, we just need to protect the ``NIOLoopBoundBox`` against mutations which we do because the ``value``
/// accessors are checking that we're on `eventLoop`.
public static func makeBoxSendingValue(
_ value: sending Value,
as: Value.Type = Value.self,
eventLoop: EventLoop
) -> NIOLoopBoundBox<Value> {
public static func makeBoxSendingValue(_ value: sending Value, as: Value.Type = Value.self, eventLoop: EventLoop) -> NIOLoopBoundBox<Value> {
// Here, we -- possibly surprisingly -- do not precondition being on the EventLoop. This is okay for a few
// reasons:
// - This function takes its value as `sending` so we don't need to worry about somebody
Expand Down
Loading