mirror of
https://github.com/apple/swift-nio
synced 2026-11-25 04:47:49 +00:00
rename the Future's functor map function to map
This commit is contained in:
1 parent
46ac01f517
commit
af4dabb0fa
5 files changed
+8
-8
No files matched your search
@@ -210,7 +210,7 @@ public final class ChannelPipeline : ChannelInvoker {
|
||||
let promise: EventLoopPromise<Bool> = self.eventLoop.newPromise()
|
||||
context0({
|
||||
return $0.handler === handler
|
||||
}).then { ctx in
|
||||
}).map { ctx in
|
||||
self.remove0(ctx: ctx, promise: promise)
|
||||
}.cascadeFailure(promise: promise)
|
||||
return promise.futureResult
|
||||
@@ -223,7 +223,7 @@ public final class ChannelPipeline : ChannelInvoker {
|
||||
/// - returns: the `EventLoopFuture` which will be notified once the `ChannelHandler` was removed.
|
||||
public func remove(name: String) -> EventLoopFuture<Bool> {
|
||||
let promise: EventLoopPromise<Bool> = self.eventLoop.newPromise()
|
||||
context0({ $0.name == name }).then { ctx in
|
||||
context0({ $0.name == name }).map { ctx in
|
||||
self.remove0(ctx: ctx, promise: promise)
|
||||
}.cascadeFailure(promise: promise)
|
||||
return promise.futureResult
|
||||
|
||||
@@ -384,7 +384,7 @@ extension EventLoopFuture {
|
||||
Generally, a simple closure provided to `then()` should never block. If you need to do something time-consuming, your closure can schedule the operation on another queue and return another `EventLoopFuture<>` object instead. See `then(queue:callback:)` for a convenient way to do this.
|
||||
*/
|
||||
|
||||
public func then<U>(file: StaticString = #file, line: UInt = #line, callback: @escaping (T) throws -> (U)) -> EventLoopFuture<U> {
|
||||
public func map<U>(file: StaticString = #file, line: UInt = #line, callback: @escaping (T) throws -> (U)) -> EventLoopFuture<U> {
|
||||
return then { return EventLoopFuture<U>(eventLoop: self.eventLoop, result: try callback($0), file: file, line: line) }
|
||||
}
|
||||
|
||||
@@ -426,7 +426,7 @@ extension EventLoopFuture {
|
||||
return next.futureResult
|
||||
}
|
||||
|
||||
public func thenIfError(file: StaticString = #file, line: UInt = #line, callback: @escaping (Error) throws -> T) -> EventLoopFuture<T> {
|
||||
public func mapIfError(file: StaticString = #file, line: UInt = #line, callback: @escaping (Error) throws -> T) -> EventLoopFuture<T> {
|
||||
return thenIfError { return EventLoopFuture<T>(eventLoop: self.eventLoop, result: try callback($0), file: file, line: line) }
|
||||
}
|
||||
|
||||
@@ -605,7 +605,7 @@ extension EventLoopFuture {
|
||||
return p0.futureResult
|
||||
}
|
||||
|
||||
let fn: EventLoopFuture<Void> = futures.reduce(p0.futureResult, { (f1: EventLoopFuture<Void>, f2: EventLoopFuture<Void>) in f1.and(f2).then(callback: { _ in return () }) })
|
||||
let fn: EventLoopFuture<Void> = futures.reduce(p0.futureResult, { (f1: EventLoopFuture<Void>, f2: EventLoopFuture<Void>) in f1.and(f2).map(callback: { _ in return () }) })
|
||||
p0.succeed(result: ())
|
||||
return fn
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ private func writeChunk(wrapOutboundOut: (IOData) -> NIOAny, ctx: ChannelHandler
|
||||
case (true, .some(let p)):
|
||||
/* chunked encoding and the user's interested: we need three promises and need to cascade into the users promise */
|
||||
let (w1, w2, w3) = (ctx.eventLoop.newPromise() as EventLoopPromise<()>, ctx.eventLoop.newPromise() as EventLoopPromise<()>, ctx.eventLoop.newPromise() as EventLoopPromise<()>)
|
||||
w1.futureResult.and(w2.futureResult).and(w3.futureResult).then { _ in () }.cascade(promise: p)
|
||||
w1.futureResult.and(w2.futureResult).and(w3.futureResult).map { _ in () }.cascade(promise: p)
|
||||
(mW1, mW2, mW3) = (w1, w2, w3)
|
||||
case (false, .some(let p)):
|
||||
/* not chunked, so just use the user's promise for the actual data */
|
||||
|
||||
@@ -402,7 +402,7 @@ public class SniHandler: ByteToMessageDecoder {
|
||||
private func sniComplete(result: SniResult, ctx: ChannelHandlerContext) {
|
||||
waitingForUser = true
|
||||
_ = completionHandler(result).then {
|
||||
ctx.pipeline?.remove(handler: self)
|
||||
ctx.pipeline!.remove(handler: self)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -95,7 +95,7 @@ public class ChannelTests: XCTestCase {
|
||||
try clientChannel.close().wait()
|
||||
|
||||
// Wait for the close promises. These fire last.
|
||||
try EventLoopFuture<Void>.andAll([clientChannel.closeFuture, serverAcceptedChannel!.closeFuture], eventLoop: group.next()).then { _ in
|
||||
try EventLoopFuture<Void>.andAll([clientChannel.closeFuture, serverAcceptedChannel!.closeFuture], eventLoop: group.next()).map { _ in
|
||||
XCTAssertEqual(clientLifecycleHandler.currentState, .unregistered)
|
||||
XCTAssertEqual(serverLifecycleHandler.currentState, .unregistered)
|
||||
XCTAssertEqual(clientLifecycleHandler.stateHistory, [.unregistered, .inactive, .active, .inactive, .unregistered])
|
||||
|
||||
Reference in new issue
Block a user