Skip to content

Commit

Permalink
Reintroduced old executeThenClose API to prevent breaking clients. Ad…
Browse files Browse the repository at this point in the history
…ded new overloaded method.
  • Loading branch information
rafaelcepeda committed Feb 25, 2025
1 parent d87d115 commit 5aed567
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions Sources/NIOCore/AsyncChannel/AsyncChannel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -278,16 +278,28 @@ public struct NIOAsyncChannel<Inbound: Sendable, Outbound: Sendable>: Sendable {
outboundWriter: outboundWriter
)
}

/// Provides scoped access to the inbound and outbound side of the underlying ``Channel``.
///
/// - Important: After this method returned the underlying ``Channel`` will be closed.
///
/// - Parameter: body: A closure that gets scoped access to the inbound and outbound.
public func executeThenClose<Result>(
_ body: (_ inbound: NIOAsyncChannelInboundStream<Inbound>, _ outbound: NIOAsyncChannelOutboundWriter<Outbound>)
async throws -> Result
) async throws -> Result {
try await executeThenClose(isolatedTo: nil, body);
}

/// Provides scoped access to the inbound and outbound side of the underlying ``Channel``.
///
/// - Important: After this method returned the underlying ``Channel`` will be closed.
///
/// - Parameter:
/// - isolatedTo: actor where this function should be isolated to
/// - 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>(
isolatedTo actor: isolated(any Actor)? = #isolation,
isolatedTo actor: isolated (any Actor)?,
_ body: (_ inbound: NIOAsyncChannelInboundStream<Inbound>, _ outbound: NIOAsyncChannelOutboundWriter<Outbound>)
async throws -> Result
) async throws -> Result {
Expand Down

0 comments on commit 5aed567

Please sign in to comment.