@@ -38,10 +38,16 @@ final class TCPThroughputBenchmark: Benchmark {
38
38
public typealias InboundIn = ByteBuffer
39
39
public typealias OutboundOut = ByteBuffer
40
40
41
+ private let connectionEstablishedPromise : EventLoopPromise < EventLoop >
41
42
private var context : ChannelHandlerContext !
42
43
44
+ init ( _ connectionEstablishedPromise: EventLoopPromise < EventLoop > ) {
45
+ self . connectionEstablishedPromise = connectionEstablishedPromise
46
+ }
47
+
43
48
public func channelActive( context: ChannelHandlerContext ) {
44
49
self . context = context
50
+ connectionEstablishedPromise. succeed ( context. eventLoop)
45
51
}
46
52
47
53
public func send( _ message: ByteBuffer , times count: Int ) {
@@ -106,12 +112,11 @@ final class TCPThroughputBenchmark: Benchmark {
106
112
func setUp( ) throws {
107
113
self . group = MultiThreadedEventLoopGroup ( numberOfThreads: 4 )
108
114
109
- let connectionEstablished : EventLoopPromise < EventLoop > = self . group. next ( ) . makePromise ( )
115
+ let connectionEstablishedPromise : EventLoopPromise < EventLoop > = self . group. next ( ) . makePromise ( )
110
116
111
117
self . serverChannel = try ServerBootstrap ( group: self . group)
112
118
. childChannelInitializer { channel in
113
- self . serverHandler = ServerHandler ( )
114
- connectionEstablished. succeed ( channel. eventLoop)
119
+ self . serverHandler = ServerHandler ( connectionEstablishedPromise)
115
120
return channel. pipeline. addHandler ( self . serverHandler)
116
121
}
117
122
. bind ( host: " 127.0.0.1 " , port: 0 )
@@ -134,7 +139,7 @@ final class TCPThroughputBenchmark: Benchmark {
134
139
}
135
140
self . message = message
136
141
137
- self . serverEventLoop = try connectionEstablished . futureResult. wait ( )
142
+ self . serverEventLoop = try connectionEstablishedPromise . futureResult. wait ( )
138
143
}
139
144
140
145
func tearDown( ) {
0 commit comments