Commit 960770d1 authored by Andrii Grynenko's avatar Andrii Grynenko Committed by Facebook Github Bot

Improve FutureAwaitable::await_ready

Summary: This helps avoid executor re-schedule when Future is ready.

Reviewed By: yfeldblum

Differential Revision: D13805939

fbshipit-source-id: f553c7a581882a7b53b004fd6bbb5087ea5787f8
parent ffff09dd
...@@ -2023,7 +2023,11 @@ class FutureAwaitable { ...@@ -2023,7 +2023,11 @@ class FutureAwaitable {
explicit FutureAwaitable(folly::Future<T>&& future) noexcept explicit FutureAwaitable(folly::Future<T>&& future) noexcept
: future_(std::move(future)) {} : future_(std::move(future)) {}
bool await_ready() const { bool await_ready() {
if (future_.isReady()) {
result_ = std::move(future_.getTry());
return true;
}
return false; return false;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment