mirror of
https://github.com/apple/swift-nio
synced 2026-11-27 05:04:22 +00:00
Motivation: For NIO's 'promise leak detector' we added file:line: labels to makePromise and there it makes sense. A user might create a promise and then never fulfil it, bad. With the file:line: arguments we can give good diagnostics. However, we (probably that @weissi again) also added it to flatMap and friends where it doesn't make sense at all. Sure, EventLoopFuture's implementation may create a promise in the implementation of flatMap but this promise is never leaked unless the previous future is never fulfilled (or NIO has a terrible bug). Suffice to say that in a future chain, it's never a flatMap etc which is responsible for leaking the first promise... Explain here the context, and why you're making that change. What is the problem you're trying to solve. Modifications: Remove all unnecessary `file:line:` parameters whilst keeping the public API intact. Result: More sensible code.
78 lines
3.6 KiB
Swift
78 lines
3.6 KiB
Swift
//===----------------------------------------------------------------------===//
|
|
//
|
|
// This source file is part of the SwiftNIO open source project
|
|
//
|
|
// Copyright (c) 2021 Apple Inc. and the SwiftNIO project authors
|
|
// Licensed under Apache License v2.0
|
|
//
|
|
// See LICENSE.txt for license information
|
|
// See CONTRIBUTORS.txt for the list of SwiftNIO project authors
|
|
//
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
extension EventLoopFuture {
|
|
@inlinable
|
|
@available(*, deprecated, message: "Please don't pass file:line:, there's no point.")
|
|
public func flatMap<NewValue>(file: StaticString = #file, line: UInt = #line, _ callback: @escaping (Value) -> EventLoopFuture<NewValue>) -> EventLoopFuture<NewValue> {
|
|
return self.flatMap(callback)
|
|
}
|
|
|
|
@inlinable
|
|
@available(*, deprecated, message: "Please don't pass file:line:, there's no point.")
|
|
public func flatMapThrowing<NewValue>(file: StaticString = #file,
|
|
line: UInt = #line,
|
|
_ callback: @escaping (Value) throws -> NewValue) -> EventLoopFuture<NewValue> {
|
|
return self.flatMapThrowing(callback)
|
|
}
|
|
|
|
@inlinable
|
|
@available(*, deprecated, message: "Please don't pass file:line:, there's no point.")
|
|
public func flatMapErrorThrowing(file: StaticString = #file, line: UInt = #line, _ callback: @escaping (Error) throws -> Value) -> EventLoopFuture<Value> {
|
|
return self.flatMapErrorThrowing(callback)
|
|
}
|
|
|
|
@inlinable
|
|
@available(*, deprecated, message: "Please don't pass file:line:, there's no point.")
|
|
public func map<NewValue>(file: StaticString = #file, line: UInt = #line, _ callback: @escaping (Value) -> (NewValue)) -> EventLoopFuture<NewValue> {
|
|
return self.map(callback)
|
|
}
|
|
|
|
@inlinable
|
|
@available(*, deprecated, message: "Please don't pass file:line:, there's no point.")
|
|
public func flatMapError(file: StaticString = #file, line: UInt = #line, _ callback: @escaping (Error) -> EventLoopFuture<Value>) -> EventLoopFuture<Value> {
|
|
return self.flatMapError(callback)
|
|
}
|
|
|
|
@inlinable
|
|
@available(*, deprecated, message: "Please don't pass file:line:, there's no point.")
|
|
public func flatMapResult<NewValue, SomeError: Error>(file: StaticString = #file,
|
|
line: UInt = #line,
|
|
_ body: @escaping (Value) -> Result<NewValue, SomeError>) -> EventLoopFuture<NewValue> {
|
|
return self.flatMapResult(body)
|
|
}
|
|
|
|
@inlinable
|
|
@available(*, deprecated, message: "Please don't pass file:line:, there's no point.")
|
|
public func recover(file: StaticString = #file, line: UInt = #line, _ callback: @escaping (Error) -> Value) -> EventLoopFuture<Value> {
|
|
return self.recover(callback)
|
|
}
|
|
|
|
@inlinable
|
|
@available(*, deprecated, message: "Please don't pass file:line:, there's no point.")
|
|
public func and<OtherValue>(_ other: EventLoopFuture<OtherValue>,
|
|
file: StaticString = #file,
|
|
line: UInt = #line) -> EventLoopFuture<(Value, OtherValue)> {
|
|
return self.and(other)
|
|
}
|
|
|
|
@inlinable
|
|
@available(*, deprecated, message: "Please don't pass file:line:, there's no point.")
|
|
public func and<OtherValue>(value: OtherValue,
|
|
file: StaticString = #file,
|
|
line: UInt = #line) -> EventLoopFuture<(Value, OtherValue)> {
|
|
return self.and(value: value)
|
|
}
|
|
}
|