Details
-
Task
-
Resolution: Gone away
-
Major - P3
-
None
-
None
-
None
-
Service Arch
-
Service Arch 2018-11-19, Service Arch 2018-12-03, Service Arch 2018-12-17, Service Arch 2018-12-31, Service Arch 2019-01-14, Service Arch 2019-01-28
Description
Right now it is easy enough to do something like
auto pf = makePromiseFuture<int>(); |
Future<void>::makeReady() |
.then([promise = pf.promise.share()]() mutable { promise.emplaceValue(1); }) |
.onError([promise = pf.promise.share()](Status s) mutable { promise.emplaceValue(2); }) |
.getAsync([](Status s) {});
|
|
|
auto result = pf.future.get();
|
without realizing that share() cannot be called twice on the same promise. This will hit this invariant, and it's not immediately clear what hitting that invariant means to someone not familiar with the futures code.
It'd be better to require
std::move(pf.promise).share()
|
SharedPromise<int> shared(std::move(promise));
|