Skip to content
This repository was archived by the owner on Aug 29, 2022. It is now read-only.

Commit bcfb7f1

Browse files
committed
Clean up how Future forwards to its children
1 parent 7178356 commit bcfb7f1

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

Sources/Deferred/ExistentialFuture.swift

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ in a playground, the following post, and the Swift standard library:
1717
*/
1818

1919
// Abstract class that fake-conforms to `FutureProtocol` for use by `Future`.
20-
private class FutureBox<Value> {
21-
func upon(_: Executor, execute _: @escaping(Value) -> Void) {
20+
private class Box<Value> {
21+
func upon(_: Future<Value>.PreferredExecutor, execute _: @escaping(Value) -> Void) {
2222
fatalError()
2323
}
2424

25-
func upon(_: DispatchQueue, execute _: @escaping(Value) -> Void) {
25+
func upon(_: Executor, execute _: @escaping(Value) -> Void) {
2626
fatalError()
2727
}
2828

@@ -36,13 +36,13 @@ private class FutureBox<Value> {
3636
}
3737

3838
// Concrete future wrapper given an instance of a `FutureProtocol`.
39-
private final class ForwardedTo<Future: FutureProtocol>: FutureBox<Future.Value> {
39+
private final class ForwardedTo<Future: FutureProtocol>: Box<Future.Value> {
4040
let base: Future
4141
init(base: Future) {
4242
self.base = base
4343
}
4444

45-
override func upon(_ executor: DispatchQueue, execute body: @escaping(Future.Value) -> Void) {
45+
override func upon(_ executor: Future.PreferredExecutor, execute body: @escaping(Future.Value) -> Void) {
4646
return base.upon(executor, execute: body)
4747
}
4848

@@ -60,13 +60,13 @@ private final class ForwardedTo<Future: FutureProtocol>: FutureBox<Future.Value>
6060
}
6161

6262
// Concrete future wrapper for an always-filled future.
63-
private final class Always<Value>: FutureBox<Value> {
63+
private final class Always<Value>: Box<Value> {
6464
let value: Value
6565
init(value: Value) {
6666
self.value = value
6767
}
6868

69-
override func upon(_ queue: DispatchQueue, execute body: @escaping(Value) -> Void) {
69+
override func upon(_ queue: Future<Value>.PreferredExecutor, execute body: @escaping(Value) -> Void) {
7070
queue.async { [value] in
7171
body(value)
7272
}
@@ -88,10 +88,10 @@ private final class Always<Value>: FutureBox<Value> {
8888
}
8989

9090
// Concrete future wrapper that will never get filled.
91-
private final class Never<Value>: FutureBox<Value> {
91+
private final class Never<Value>: Box<Value> {
9292
override init() {}
9393

94-
override func upon(_: DispatchQueue, execute _: @escaping(Value) -> Void) {}
94+
override func upon(_: Future<Value>.PreferredExecutor, execute _: @escaping(Value) -> Void) {}
9595

9696
override func upon(_: Executor, execute _: @escaping(Value) -> Void) {}
9797

@@ -117,7 +117,7 @@ private final class Never<Value>: FutureBox<Value> {
117117
/// ensuring that only your implementation can fill the deferred value
118118
/// using the `PromiseProtocol` aspect.
119119
public struct Future<Value>: FutureProtocol {
120-
private let box: FutureBox<Value>
120+
private let box: Box<Value>
121121

122122
/// Create a future whose `upon(_:execute:)` methods forward to `base`.
123123
public init<OtherFuture: FutureProtocol>(_ base: OtherFuture)
@@ -144,7 +144,7 @@ public struct Future<Value>: FutureProtocol {
144144
self.box = other.box
145145
}
146146

147-
public func upon(_ queue: DispatchQueue, execute body: @escaping(Value) -> Void) {
147+
public func upon(_ queue: PreferredExecutor, execute body: @escaping(Value) -> Void) {
148148
return box.upon(queue, execute: body)
149149
}
150150

0 commit comments

Comments
 (0)