Skip to content

Commit

Permalink
improvement: pass down file/line in makeFutureWithTask
Browse files Browse the repository at this point in the history
In some circumstances it can be difficult to know which specific call to
makeFutureWithTask leaked a promise. Passes through file/line to help
aid debugging such situations.
  • Loading branch information
Austinpayne committed May 1, 2024
1 parent 447b281 commit ea16fc3
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions Sources/NIOCore/AsyncAwaitSupport.swift
Original file line number Diff line number Diff line change
Expand Up @@ -339,8 +339,12 @@ struct AsyncSequenceFromIterator<AsyncIterator: AsyncIteratorProtocol>: AsyncSeq
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
extension EventLoop {
@inlinable
public func makeFutureWithTask<Return>(_ body: @Sendable @escaping () async throws -> Return) -> EventLoopFuture<Return> {
let promise = self.makePromise(of: Return.self)
public func makeFutureWithTask<Return>(
file: StaticString = #fileID,
line: UInt = #line,
_ body: @Sendable @escaping () async throws -> Return
) -> EventLoopFuture<Return> {
let promise = self.makePromise(of: Return.self, file: file, line: line)
promise.completeWithTask(body)
return promise.futureResult
}
Expand Down

0 comments on commit ea16fc3

Please sign in to comment.