Skip to content

Commit

Permalink
Merge branch 'main' into dimitri/parts-docs
Browse files Browse the repository at this point in the history
  • Loading branch information
glbrntt authored Jul 12, 2024
2 parents e4006f5 + 0f4c110 commit 78b9505
Show file tree
Hide file tree
Showing 11 changed files with 292 additions and 378 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"mallocCountTotal" : 12
"mallocCountTotal" : 10
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"mallocCountTotal" : 12
"mallocCountTotal" : 10
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"mallocCountTotal" : 12
"mallocCountTotal" : 10
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"mallocCountTotal" : 12
"mallocCountTotal" : 10
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"mallocCountTotal" : 12
"mallocCountTotal" : 10
}
37 changes: 29 additions & 8 deletions Sources/NIOCore/AsyncChannel/AsyncChannel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -315,16 +315,27 @@ extension Channel {
) throws -> (NIOAsyncChannelInboundStream<Inbound>, NIOAsyncChannelOutboundWriter<Outbound>) {
self.eventLoop.assertInEventLoop()

let inboundStream = try NIOAsyncChannelInboundStream<Inbound>.makeWrappingHandler(
channel: self,
let handler = NIOAsyncChannelHandler<Inbound, Inbound, Outbound>(
eventLoop: self.eventLoop,
transformation: .syncWrapping { $0 },
isOutboundHalfClosureEnabled: isOutboundHalfClosureEnabled
)

let inboundStream = try NIOAsyncChannelInboundStream(
eventLoop: self.eventLoop,
handler: handler,
backPressureStrategy: backPressureStrategy,
closeOnDeinit: closeOnDeinit
)

let writer = try NIOAsyncChannelOutboundWriter<Outbound>(
channel: self,
eventLoop: self.eventLoop,
handler: handler,
isOutboundHalfClosureEnabled: isOutboundHalfClosureEnabled,
closeOnDeinit: closeOnDeinit
)

try self.pipeline.syncOperations.addHandler(handler)
return (inboundStream, writer)
}

Expand All @@ -338,17 +349,27 @@ extension Channel {
) throws -> (NIOAsyncChannelInboundStream<ChannelReadResult>, NIOAsyncChannelOutboundWriter<Never>) {
self.eventLoop.assertInEventLoop()

let inboundStream = try NIOAsyncChannelInboundStream<ChannelReadResult>.makeTransformationHandler(
channel: self,
let handler = NIOAsyncChannelHandler<Channel, ChannelReadResult, Never>(
eventLoop: self.eventLoop,
transformation: .transformation(channelReadTransformation: channelReadTransformation),
isOutboundHalfClosureEnabled: isOutboundHalfClosureEnabled
)

let inboundStream = try NIOAsyncChannelInboundStream(
eventLoop: self.eventLoop,
handler: handler,
backPressureStrategy: backPressureStrategy,
closeOnDeinit: closeOnDeinit,
channelReadTransformation: channelReadTransformation
closeOnDeinit: closeOnDeinit
)

let writer = try NIOAsyncChannelOutboundWriter<Never>(
channel: self,
eventLoop: self.eventLoop,
handler: handler,
isOutboundHalfClosureEnabled: isOutboundHalfClosureEnabled,
closeOnDeinit: closeOnDeinit
)

try self.pipeline.syncOperations.addHandler(handler)
return (inboundStream, writer)
}
}
Loading

0 comments on commit 78b9505

Please sign in to comment.