@@ -184,17 +184,6 @@ public struct EventLoopPromise<Value> {
184
184
self . _resolve ( value: . success( value) )
185
185
}
186
186
187
- /// Deliver a successful result to the associated `EventLoopFuture<Value>` object.
188
- ///
189
- /// - Note: The call to this method must happen on the same event loop as this promise was created from.
190
- ///
191
- /// - parameters:
192
- /// - eventLoopBoundValue: The successful result of the operation.
193
- @inlinable
194
- public func succeed( eventLoopBoundValue: Value ) {
195
- self . _resolve ( eventLoopBoundResult: . success( eventLoopBoundValue) )
196
- }
197
-
198
187
/// Deliver an error to the associated `EventLoopFuture<Value>` object.
199
188
///
200
189
/// - parameters:
@@ -247,27 +236,6 @@ public struct EventLoopPromise<Value> {
247
236
self . _resolve ( value: result)
248
237
}
249
238
250
- /// Complete the promise with the passed in `Result<Value, Error>`.
251
- ///
252
- /// This method is equivalent to invoking:
253
- /// ```
254
- /// switch result {
255
- /// case .success(let value):
256
- /// promise.succeed(value)
257
- /// case .failure(let error):
258
- /// promise.fail(error)
259
- /// }
260
- /// ```
261
- ///
262
- /// - Note: The call to this method must happen on the same event loop as this promise was created from.
263
- ///
264
- /// - parameters:
265
- /// - result: The result which will be used to succeed or fail this promise.
266
- @inlinable
267
- public func completeWith( eventLoopBoundResult: Result < Value , Error > ) {
268
- self . _resolve ( eventLoopBoundResult: eventLoopBoundResult)
269
- }
270
-
271
239
/// Fire the associated `EventLoopFuture` on the appropriate event loop.
272
240
///
273
241
/// This method provides the primary difference between the `EventLoopPromise` and most
@@ -287,23 +255,6 @@ public struct EventLoopPromise<Value> {
287
255
}
288
256
}
289
257
290
- /// Fire the associated `EventLoopFuture` on the appropriate event loop.
291
- ///
292
- /// This method provides the primary difference between the `EventLoopPromise` and most
293
- /// other `Promise` implementations: specifically, all callbacks fire on the `EventLoop`
294
- /// that was used to create the promise.
295
- ///
296
- /// - Note: The call to this method must happen on the same event loop as this promise was created from.
297
- ///
298
- /// - parameters:
299
- /// - value: The value to fire the future with.
300
- @inlinable
301
- internal func _resolve( eventLoopBoundResult: Result < Value , Error > ) {
302
- self . futureResult. eventLoop. assertInEventLoop ( )
303
-
304
- self . _setValue ( value: eventLoopBoundResult) . _run ( )
305
- }
306
-
307
258
/// Set the future result and get the associated callbacks.
308
259
///
309
260
/// - parameters:
@@ -1435,17 +1386,17 @@ extension EventLoopFuture {
1435
1386
processResult ( index, . success( ( ) ) )
1436
1387
case . failure( let error) :
1437
1388
processResult ( index, . failure( error) )
1438
- }
1439
- if case . failure = result {
1440
- return // Once the promise is failed, future results do not need to be processed.
1389
+ return
1441
1390
}
1442
1391
} else {
1443
1392
// We have to map to `Void` here to avoid sharing the potentially non-Sendable
1444
1393
// value across event loops.
1445
- future
1446
- . map { _ in ( ) }
1447
- . hop ( to: eventLoop)
1448
- . whenComplete { result in processResult ( index, result) }
1394
+ future. whenComplete { result in
1395
+ let voidResult = result. map { _ in }
1396
+ future. eventLoop. execute {
1397
+ processResult ( index, voidResult)
1398
+ }
1399
+ }
1449
1400
}
1450
1401
}
1451
1402
}
@@ -1661,10 +1612,12 @@ extension EventLoopFuture {
1661
1612
} else {
1662
1613
// We have to map to `Void` here to avoid sharing the potentially non-Sendable
1663
1614
// value across event loops.
1664
- future
1665
- . map { _ in ( ) }
1666
- . hop ( to: eventLoop)
1667
- . whenComplete { result in processResult ( index, result) }
1615
+ future. whenComplete { result in
1616
+ let voidResult = result. map { _ in }
1617
+ future. eventLoop. execute {
1618
+ processResult ( index, voidResult)
1619
+ }
1620
+ }
1668
1621
}
1669
1622
}
1670
1623
}
0 commit comments