X-Git-Url: http://plrg.eecs.uci.edu/git/?a=blobdiff_plain;f=folly%2Ffutures%2FPromise-inl.h;h=45e6929a9152a7bc0bf4750cf7583e8da4a684e3;hb=b22d1721ed9c062e22b33936e13b39ed1507391a;hp=5fe4ed2cb029c782c39e3f54ac9fa2fdb0fc2222;hpb=1eccb2e616d848a21699bd11b04622d0ef7b07c3;p=folly.git diff --git a/folly/futures/Promise-inl.h b/folly/futures/Promise-inl.h index 5fe4ed2c..45e6929a 100644 --- a/folly/futures/Promise-inl.h +++ b/folly/futures/Promise-inl.h @@ -19,6 +19,7 @@ #include #include +#include #include #include @@ -76,18 +77,26 @@ Promise::~Promise() { template void Promise::detach() { if (core_) { - if (!retrieved_) + if (!retrieved_) { core_->detachFuture(); + } core_->detachPromise(); core_ = nullptr; } } template -Future Promise::getFuture() { +SemiFuture Promise::getSemiFuture() { throwIfRetrieved(); retrieved_ = true; - return Future(core_); + return SemiFuture(core_); +} + +template +Future Promise::getFuture() { + // An InlineExecutor approximates the old behaviour of continuations + // running inine on setting the value of the promise. + return getSemiFuture().via(&InlineExecutor::instance()); } template @@ -144,4 +153,4 @@ bool Promise::isFulfilled() const noexcept { return true; } -} +} // namespace folly