Commit 56effb5a authored by Yedidya Feldblum's avatar Yedidya Feldblum Committed by Facebook GitHub Bot

reexport coroutine_handle

Summary: Reexport `coroutine_handle` from `folly/experimental/coro/Coroutine.h`, which wraps inclusion of `experimental/coroutine`.

Differential Revision: D26227588

fbshipit-source-id: 32cdb2b6d87e90065bf9f140716d63670c04db5f
parent ce0961de
......@@ -52,8 +52,8 @@ class AsyncGeneratorPromise {
class YieldAwaiter {
public:
bool await_ready() noexcept { return false; }
std::experimental::coroutine_handle<> await_suspend(
std::experimental::coroutine_handle<AsyncGeneratorPromise> h) noexcept {
coroutine_handle<> await_suspend(
coroutine_handle<AsyncGeneratorPromise> h) noexcept {
AsyncGeneratorPromise& promise = h.promise();
// Pop AsyncStackFrame first as clearContext() clears the frame state.
folly::popAsyncStackFrameCallee(promise.getAsyncFrame());
......@@ -194,8 +194,7 @@ class AsyncGeneratorPromise {
executor_ = std::move(executor);
}
void setContinuation(
std::experimental::coroutine_handle<> continuation) noexcept {
void setContinuation(coroutine_handle<> continuation) noexcept {
continuation_ = continuation;
}
......@@ -253,7 +252,7 @@ class AsyncGeneratorPromise {
DONE,
};
std::experimental::coroutine_handle<> continuation_;
coroutine_handle<> continuation_;
folly::AsyncStackFrame asyncFrame_;
folly::Executor::KeepAlive<> executor_;
folly::CancellationToken cancelToken_;
......@@ -366,7 +365,7 @@ class FOLLY_NODISCARD AsyncGenerator {
using promise_type = detail::AsyncGeneratorPromise<Reference, Value>;
private:
using handle_t = std::experimental::coroutine_handle<promise_type>;
using handle_t = coroutine_handle<promise_type>;
public:
using value_type = Value;
......@@ -489,7 +488,7 @@ class FOLLY_NODISCARD AsyncGenerator {
template <typename Promise>
FOLLY_NOINLINE auto await_suspend(
std::experimental::coroutine_handle<Promise> continuation) noexcept {
coroutine_handle<Promise> continuation) noexcept {
auto& promise = coro_.promise();
promise.setContinuation(continuation);
......@@ -586,11 +585,10 @@ class FOLLY_NODISCARD AsyncGenerator {
private:
friend class detail::AsyncGeneratorPromise<Reference, Value>;
explicit AsyncGenerator(
std::experimental::coroutine_handle<promise_type> coro) noexcept
explicit AsyncGenerator(coroutine_handle<promise_type> coro) noexcept
: coro_(coro) {}
std::experimental::coroutine_handle<promise_type> coro_;
coroutine_handle<promise_type> coro_;
};
namespace detail {
......@@ -598,8 +596,9 @@ namespace detail {
template <typename Reference, typename Value>
AsyncGenerator<Reference, Value>
AsyncGeneratorPromise<Reference, Value>::get_return_object() noexcept {
return AsyncGenerator<Reference, Value>{std::experimental::coroutine_handle<
AsyncGeneratorPromise<Reference, Value>>::from_promise(*this)};
return AsyncGenerator<Reference, Value>{
coroutine_handle<AsyncGeneratorPromise<Reference, Value>>::from_promise(
*this)};
}
} // namespace detail
......
......@@ -33,8 +33,7 @@ class AsyncStackTraceAwaitable {
bool await_ready() const { return false; }
template <typename Promise>
bool await_suspend(
std::experimental::coroutine_handle<Promise> h) noexcept {
bool await_suspend(coroutine_handle<Promise> h) noexcept {
initialFrame_ = &h.promise().getAsyncFrame();
return false;
}
......
......@@ -95,8 +95,7 @@ class Baton {
bool await_ready() const noexcept { return baton_.ready(); }
bool await_suspend(
std::experimental::coroutine_handle<> awaitingCoroutine) noexcept {
bool await_suspend(coroutine_handle<> awaitingCoroutine) noexcept {
awaitingCoroutine_ = awaitingCoroutine;
return baton_.waitImpl(this);
}
......@@ -107,7 +106,7 @@ class Baton {
friend class Baton;
const Baton& baton_;
std::experimental::coroutine_handle<> awaitingCoroutine_;
coroutine_handle<> awaitingCoroutine_;
WaitOperation* next_;
};
......
......@@ -48,8 +48,7 @@ class BlockingWaitPromiseBase {
struct FinalAwaiter {
bool await_ready() noexcept { return false; }
template <typename Promise>
void await_suspend(
std::experimental::coroutine_handle<Promise> coro) noexcept {
void await_suspend(coroutine_handle<Promise> coro) noexcept {
BlockingWaitPromiseBase& promise = coro.promise();
folly::deactivateAsyncStackFrame(promise.getAsyncFrame());
promise.baton_.post();
......@@ -186,7 +185,7 @@ template <typename T>
class BlockingWaitTask {
public:
using promise_type = BlockingWaitPromise<T>;
using handle_t = std::experimental::coroutine_handle<promise_type>;
using handle_t = coroutine_handle<promise_type>;
explicit BlockingWaitTask(handle_t coro) noexcept : coro_(coro) {}
......@@ -247,21 +246,20 @@ template <typename T>
inline BlockingWaitTask<T>
BlockingWaitPromise<T>::get_return_object() noexcept {
return BlockingWaitTask<T>{
std::experimental::coroutine_handle<BlockingWaitPromise<T>>::from_promise(
*this)};
coroutine_handle<BlockingWaitPromise<T>>::from_promise(*this)};
}
template <typename T>
inline BlockingWaitTask<T&>
BlockingWaitPromise<T&>::get_return_object() noexcept {
return BlockingWaitTask<T&>{std::experimental::coroutine_handle<
BlockingWaitPromise<T&>>::from_promise(*this)};
return BlockingWaitTask<T&>{
coroutine_handle<BlockingWaitPromise<T&>>::from_promise(*this)};
}
inline BlockingWaitTask<void>
BlockingWaitPromise<void>::get_return_object() noexcept {
return BlockingWaitTask<void>{std::experimental::coroutine_handle<
BlockingWaitPromise<void>>::from_promise(*this)};
return BlockingWaitTask<void>{
coroutine_handle<BlockingWaitPromise<void>>::from_promise(*this)};
}
template <
......
......@@ -28,6 +28,7 @@
namespace folly::coro {
using std::experimental::coroutine_handle;
using std::experimental::suspend_always;
using std::experimental::suspend_never;
......
......@@ -75,14 +75,13 @@ class co_reschedule_on_current_executor_ {
using AwaiterBase::AwaiterBase;
template <typename Promise>
void await_suspend(
std::experimental::coroutine_handle<Promise> coro) noexcept {
void await_suspend(coroutine_handle<Promise> coro) noexcept {
await_suspend_impl(coro, coro.promise().getAsyncFrame());
}
private:
FOLLY_CORO_AWAIT_SUSPEND_NONTRIVIAL_ATTRIBUTES void await_suspend_impl(
std::experimental::coroutine_handle<> coro,
coroutine_handle<> coro,
AsyncStackFrame& frame) {
auto& stackRoot = *frame.getStackRoot();
folly::deactivateAsyncStackFrame(frame);
......@@ -104,7 +103,7 @@ class co_reschedule_on_current_executor_ {
using AwaiterBase::AwaiterBase;
FOLLY_CORO_AWAIT_SUSPEND_NONTRIVIAL_ATTRIBUTES void await_suspend(
std::experimental::coroutine_handle<> coro) {
coroutine_handle<> coro) {
executor_->add([coro, ctx = RequestContext::saveContext()]() mutable {
RequestContextScopeGuard contextScope{std::move(ctx)};
coro.resume();
......
......@@ -75,8 +75,7 @@ class Generator {
bool await_ready() noexcept { return this->m_childPromise == nullptr; }
void await_suspend(
std::experimental::coroutine_handle<promise_type>) noexcept {}
void await_suspend(coroutine_handle<promise_type>) noexcept {}
void await_resume() {
if (this->m_childPromise != nullptr) {
......@@ -110,8 +109,7 @@ class Generator {
void await_transform(U&& value) = delete;
void destroy() noexcept {
std::experimental::coroutine_handle<promise_type>::from_promise(*this)
.destroy();
coroutine_handle<promise_type>::from_promise(*this).destroy();
}
void throw_if_exception() {
......@@ -121,9 +119,7 @@ class Generator {
}
bool is_complete() noexcept {
return std::experimental::coroutine_handle<promise_type>::from_promise(
*this)
.done();
return coroutine_handle<promise_type>::from_promise(*this).done();
}
T& value() noexcept {
......@@ -146,8 +142,7 @@ class Generator {
private:
void resume() noexcept {
std::experimental::coroutine_handle<promise_type>::from_promise(*this)
.resume();
coroutine_handle<promise_type>::from_promise(*this).resume();
}
std::add_pointer_t<T> m_value;
......
......@@ -163,8 +163,7 @@ class Mutex {
bool await_ready() noexcept { return mutex_.try_lock(); }
bool await_suspend(
std::experimental::coroutine_handle<> awaitingCoroutine) noexcept {
bool await_suspend(coroutine_handle<> awaitingCoroutine) noexcept {
awaitingCoroutine_ = awaitingCoroutine;
return mutex_.lockAsyncImpl(this);
}
......@@ -177,7 +176,7 @@ class Mutex {
private:
friend Mutex;
std::experimental::coroutine_handle<> awaitingCoroutine_;
coroutine_handle<> awaitingCoroutine_;
LockAwaiter* next_;
};
......
......@@ -206,7 +206,7 @@ class SharedMutexFair {
SharedMutexFair* mutex_;
LockAwaiterBase* nextAwaiter_;
LockAwaiterBase* nextReader_;
std::experimental::coroutine_handle<> continuation_;
coroutine_handle<> continuation_;
LockType lockType_;
};
......@@ -218,7 +218,7 @@ class SharedMutexFair {
bool await_ready() noexcept { return mutex_->try_lock(); }
FOLLY_CORO_AWAIT_SUSPEND_NONTRIVIAL_ATTRIBUTES bool await_suspend(
std::experimental::coroutine_handle<> continuation) noexcept {
coroutine_handle<> continuation) noexcept {
auto lock = mutex_->state_.contextualLock();
// Exclusive lock can only be acquired if it's currently unlocked.
......@@ -245,7 +245,7 @@ class SharedMutexFair {
bool await_ready() noexcept { return mutex_->try_lock_shared(); }
FOLLY_CORO_AWAIT_SUSPEND_NONTRIVIAL_ATTRIBUTES bool await_suspend(
std::experimental::coroutine_handle<> continuation) noexcept {
coroutine_handle<> continuation) noexcept {
auto lock = mutex_->state_.contextualLock();
// shared-lock can be acquired if it's either unlocked or it is
......
......@@ -63,10 +63,8 @@ class TaskPromiseBase {
bool await_ready() noexcept { return false; }
template <typename Promise>
FOLLY_CORO_AWAIT_SUSPEND_NONTRIVIAL_ATTRIBUTES
std::experimental::coroutine_handle<>
await_suspend(
std::experimental::coroutine_handle<Promise> coro) noexcept {
FOLLY_CORO_AWAIT_SUSPEND_NONTRIVIAL_ATTRIBUTES coroutine_handle<>
await_suspend(coroutine_handle<Promise> coro) noexcept {
TaskPromiseBase& promise = coro.promise();
folly::popAsyncStackFrameCallee(promise.asyncFrame_);
return promise.continuation_;
......@@ -134,7 +132,7 @@ class TaskPromiseBase {
template <typename T>
friend class folly::coro::Task;
std::experimental::coroutine_handle<> continuation_;
coroutine_handle<> continuation_;
folly::AsyncStackFrame asyncFrame_;
folly::Executor::KeepAlive<> executor_;
folly::CancellationToken cancelToken_;
......@@ -258,7 +256,7 @@ class TaskPromise<void> : public TaskPromiseBase {
/// completes.
template <typename T>
class FOLLY_NODISCARD TaskWithExecutor {
using handle_t = std::experimental::coroutine_handle<detail::TaskPromise<T>>;
using handle_t = coroutine_handle<detail::TaskPromise<T>>;
using StorageType = typename detail::TaskPromise<T>::StorageType;
public:
......@@ -402,7 +400,7 @@ class FOLLY_NODISCARD TaskWithExecutor {
template <typename Promise>
FOLLY_NOINLINE void await_suspend(
std::experimental::coroutine_handle<Promise> continuation) noexcept {
coroutine_handle<Promise> continuation) noexcept {
DCHECK(coro_);
auto& promise = coro_.promise();
DCHECK(!promise.continuation_);
......@@ -466,8 +464,8 @@ class FOLLY_NODISCARD TaskWithExecutor {
bool await_ready() { return false; }
template <typename Promise>
FOLLY_NOINLINE std::experimental::coroutine_handle<> await_suspend(
std::experimental::coroutine_handle<Promise> continuation) {
FOLLY_NOINLINE coroutine_handle<> await_suspend(
coroutine_handle<Promise> continuation) {
DCHECK(coro_);
auto& promise = coro_.promise();
DCHECK(!promise.continuation_);
......@@ -564,7 +562,7 @@ class FOLLY_NODISCARD Task {
private:
class Awaiter;
using handle_t = std::experimental::coroutine_handle<promise_type>;
using handle_t = coroutine_handle<promise_type>;
void setExecutor(folly::Executor::KeepAlive<>&& e) noexcept {
DCHECK(coro_);
......@@ -665,7 +663,7 @@ class FOLLY_NODISCARD Task {
template <typename Promise>
FOLLY_NOINLINE auto await_suspend(
std::experimental::coroutine_handle<Promise> continuation) noexcept {
coroutine_handle<Promise> continuation) noexcept {
DCHECK(coro_);
auto& promise = coro_.promise();
......@@ -742,14 +740,12 @@ Task<drop_unit_t<T>> makeResultTask(Try<T> t) {
template <typename T>
Task<T> detail::TaskPromise<T>::get_return_object() noexcept {
return Task<T>{
std::experimental::coroutine_handle<detail::TaskPromise<T>>::from_promise(
*this)};
return Task<T>{coroutine_handle<detail::TaskPromise<T>>::from_promise(*this)};
}
inline Task<void> detail::TaskPromise<void>::get_return_object() noexcept {
return Task<void>{std::experimental::coroutine_handle<
detail::TaskPromise<void>>::from_promise(*this)};
return Task<void>{
coroutine_handle<detail::TaskPromise<void>>::from_promise(*this)};
}
} // namespace coro
......
......@@ -45,7 +45,7 @@ namespace detail {
template <typename T>
inline constexpr bool is_coroutine_handle_v =
folly::detail::is_instantiation_of_v< //
std::experimental::coroutine_handle,
coroutine_handle,
T>;
} // namespace detail
......@@ -58,10 +58,10 @@ inline constexpr bool is_coroutine_handle_v =
///
/// An 'Awaiter' must have the following three methods.
/// - awaiter.await_ready() -> bool
/// - awaiter.await_suspend(std::experimental::coroutine_handle<void>()) ->
/// - awaiter.await_suspend(coroutine_handle<void>()) ->
/// void OR
/// bool OR
/// std::experimental::coroutine_handle<T> for some T
/// coroutine_handle<T> for some T
/// - awaiter.await_resume()
///
/// Note that we don't check for a valid await_suspend() method here since
......
......@@ -37,7 +37,7 @@ class AwaitableReady {
bool await_ready() noexcept { return true; }
void await_suspend(std::experimental::coroutine_handle<>) noexcept {}
void await_suspend(coroutine_handle<>) noexcept {}
T await_resume() noexcept(std::is_nothrow_move_constructible<T>::value) {
return static_cast<T&&>(value_);
......@@ -52,7 +52,7 @@ class AwaitableReady<void> {
public:
AwaitableReady() noexcept = default;
bool await_ready() noexcept { return true; }
void await_suspend(std::experimental::coroutine_handle<>) noexcept {}
void await_suspend(coroutine_handle<>) noexcept {}
void await_resume() noexcept {}
};
......@@ -60,9 +60,7 @@ namespace detail {
struct await_suspend_return_coroutine_fn {
template <typename A, typename P>
std::experimental::coroutine_handle<> operator()(
A& a,
std::experimental::coroutine_handle<P> coro) const
coroutine_handle<> operator()(A& a, coroutine_handle<P> coro) const
noexcept(noexcept(a.await_suspend(coro))) {
using result = decltype(a.await_suspend(coro));
auto noop = std::experimental::noop_coroutine();
......@@ -84,9 +82,6 @@ class AwaitableVariant : private std::variant<A...> {
private:
using base = std::variant<A...>;
template <typename P = void>
using handle = std::experimental::coroutine_handle<P>;
template <typename Visitor>
auto visit(Visitor v) {
return std::visit(v, static_cast<base&>(*this));
......@@ -100,7 +95,7 @@ class AwaitableVariant : private std::variant<A...> {
return visit([&](auto& a) { return a.await_ready(); });
}
template <typename P>
auto await_suspend(handle<P> coro) noexcept(
auto await_suspend(coroutine_handle<P> coro) noexcept(
(noexcept(FOLLY_DECLVAL(A&).await_suspend(coro)) && ...)) {
auto impl = await_suspend_return_coroutine;
return visit([&](auto& a) { return impl(a, coro); });
......
......@@ -63,8 +63,7 @@ class ViaCoroutinePromiseBase {
executor_ = std::move(executor);
}
void setContinuation(
std::experimental::coroutine_handle<> continuation) noexcept {
void setContinuation(coroutine_handle<> continuation) noexcept {
continuation_ = continuation;
}
......@@ -94,7 +93,7 @@ class ViaCoroutinePromiseBase {
protected:
folly::Executor::KeepAlive<> executor_;
std::experimental::coroutine_handle<> continuation_;
coroutine_handle<> continuation_;
folly::AsyncStackFrame* asyncFrame_ = nullptr;
std::shared_ptr<RequestContext> context_;
};
......@@ -107,7 +106,7 @@ class ViaCoroutine {
bool await_ready() noexcept { return false; }
FOLLY_CORO_AWAIT_SUSPEND_NONTRIVIAL_ATTRIBUTES void await_suspend(
std::experimental::coroutine_handle<promise_type> h) noexcept {
coroutine_handle<promise_type> h) noexcept {
auto& promise = h.promise();
if (!promise.context_) {
promise.setRequestContext(RequestContext::saveContext());
......@@ -125,9 +124,7 @@ class ViaCoroutine {
public:
ViaCoroutine get_return_object() noexcept {
return ViaCoroutine{
std::experimental::coroutine_handle<promise_type>::from_promise(
*this)};
return ViaCoroutine{coroutine_handle<promise_type>::from_promise(*this)};
}
FinalAwaiter final_suspend() noexcept { return {}; }
......@@ -160,8 +157,7 @@ class ViaCoroutine {
coro_.promise().setExecutor(std::move(executor));
}
void setContinuation(
std::experimental::coroutine_handle<> continuation) noexcept {
void setContinuation(coroutine_handle<> continuation) noexcept {
coro_.promise().setContinuation(continuation);
}
......@@ -179,18 +175,15 @@ class ViaCoroutine {
coro_.promise().setRequestContext(folly::RequestContext::saveContext());
}
std::experimental::coroutine_handle<promise_type> getHandle() noexcept {
return coro_;
}
coroutine_handle<promise_type> getHandle() noexcept { return coro_; }
private:
explicit ViaCoroutine(
std::experimental::coroutine_handle<promise_type> coro) noexcept
explicit ViaCoroutine(coroutine_handle<promise_type> coro) noexcept
: coro_(coro) {}
static ViaCoroutine createImpl() { co_return; }
std::experimental::coroutine_handle<promise_type> coro_;
coroutine_handle<promise_type> coro_;
};
} // namespace detail
......@@ -202,7 +195,7 @@ class StackAwareViaIfAsyncAwaiter {
using Awaiter = folly::coro::awaiter_type_t<WithAsyncStackAwaitable>;
using CoroutineType = detail::ViaCoroutine<true>;
using CoroutinePromise = typename CoroutineType::promise_type;
using WrapperHandle = std::experimental::coroutine_handle<CoroutinePromise>;
using WrapperHandle = coroutine_handle<CoroutinePromise>;
using await_suspend_result_t = decltype(
std::declval<Awaiter&>().await_suspend(std::declval<WrapperHandle>()));
......@@ -222,9 +215,9 @@ class StackAwareViaIfAsyncAwaiter {
}
template <typename Promise>
auto await_suspend(std::experimental::coroutine_handle<Promise> h) noexcept(
noexcept(std::declval<Awaiter&>().await_suspend(
std::declval<WrapperHandle>()))) -> await_suspend_result_t {
auto await_suspend(coroutine_handle<Promise> h) noexcept(noexcept(
std::declval<Awaiter&>().await_suspend(std::declval<WrapperHandle>())))
-> await_suspend_result_t {
auto& promise = h.promise();
auto& asyncFrame = promise.getAsyncFrame();
......@@ -263,7 +256,7 @@ class ViaIfAsyncAwaiter {
using Awaiter = folly::coro::awaiter_type_t<Awaitable>;
using CoroutineType = detail::ViaCoroutine<false>;
using CoroutinePromise = typename CoroutineType::promise_type;
using WrapperHandle = std::experimental::coroutine_handle<CoroutinePromise>;
using WrapperHandle = coroutine_handle<CoroutinePromise>;
using await_suspend_result_t = decltype(
std::declval<Awaiter&>().await_suspend(std::declval<WrapperHandle>()));
......@@ -309,11 +302,8 @@ class ViaIfAsyncAwaiter {
// case.
template <typename Promise>
auto await_suspend(
std::experimental::coroutine_handle<Promise>
continuation) noexcept(noexcept(awaiter_
.await_suspend(std::declval<
WrapperHandle>())))
auto await_suspend(coroutine_handle<Promise> continuation) noexcept(
noexcept(awaiter_.await_suspend(std::declval<WrapperHandle>())))
-> await_suspend_result_t {
viaCoroutine_.setContinuation(continuation);
......@@ -520,8 +510,7 @@ class TryAwaiter {
}
template <typename Promise>
auto
await_suspend(std::experimental::coroutine_handle<Promise> coro) noexcept(
auto await_suspend(coroutine_handle<Promise> coro) noexcept(
noexcept(std::declval<Awaiter&>().await_suspend(coro)))
-> decltype(std::declval<Awaiter&>().await_suspend(coro)) {
return awaiter_.await_suspend(coro);
......
......@@ -39,16 +39,14 @@ class WithAsyncStackCoroutine {
public:
WithAsyncStackCoroutine get_return_object() noexcept {
return WithAsyncStackCoroutine{
std::experimental::coroutine_handle<promise_type>::from_promise(
*this)};
coroutine_handle<promise_type>::from_promise(*this)};
}
suspend_always initial_suspend() noexcept { return {}; }
struct FinalAwaiter {
bool await_ready() noexcept { return false; }
void await_suspend(
std::experimental::coroutine_handle<promise_type> h) noexcept {
void await_suspend(coroutine_handle<promise_type> h) noexcept {
auto& promise = h.promise();
folly::resumeCoroutineWithNewAsyncStackRoot(
promise.continuation_, *promise.parentFrame_);
......@@ -68,7 +66,7 @@ class WithAsyncStackCoroutine {
private:
friend WithAsyncStackCoroutine;
std::experimental::coroutine_handle<> continuation_;
coroutine_handle<> continuation_;
folly::AsyncStackFrame* parentFrame_ = nullptr;
};
......@@ -91,8 +89,8 @@ class WithAsyncStackCoroutine {
static WithAsyncStackCoroutine create() { co_return; }
template <typename Promise>
std::experimental::coroutine_handle<promise_type> getWrapperHandleFor(
std::experimental::coroutine_handle<Promise> h) noexcept {
coroutine_handle<promise_type> getWrapperHandleFor(
coroutine_handle<Promise> h) noexcept {
auto& promise = coro_.promise();
promise.continuation_ = h;
promise.parentFrame_ = std::addressof(h.promise().getAsyncFrame());
......@@ -100,11 +98,10 @@ class WithAsyncStackCoroutine {
}
private:
explicit WithAsyncStackCoroutine(
std::experimental::coroutine_handle<promise_type> h) noexcept
explicit WithAsyncStackCoroutine(coroutine_handle<promise_type> h) noexcept
: coro_(h) {}
std::experimental::coroutine_handle<promise_type> coro_;
coroutine_handle<promise_type> coro_;
};
template <typename Awaitable>
......@@ -123,7 +120,7 @@ class WithAsyncStackAwaiter {
template <typename Promise>
FOLLY_CORO_AWAIT_SUSPEND_NONTRIVIAL_ATTRIBUTES auto await_suspend(
std::experimental::coroutine_handle<Promise> h) {
coroutine_handle<Promise> h) {
AsyncStackFrame& callerFrame = h.promise().getAsyncFrame();
AsyncStackRoot* stackRoot = callerFrame.getStackRoot();
assert(stackRoot != nullptr);
......
......@@ -63,7 +63,7 @@ class Barrier {
return count_.load(std::memory_order_acquire);
}
[[nodiscard]] std::experimental::coroutine_handle<> arrive(
[[nodiscard]] coroutine_handle<> arrive(
folly::AsyncStackFrame& currentFrame) noexcept {
auto& stackRoot = *currentFrame.getStackRoot();
folly::deactivateAsyncStackFrame(currentFrame);
......@@ -84,7 +84,7 @@ class Barrier {
}
}
[[nodiscard]] std::experimental::coroutine_handle<> arrive() noexcept {
[[nodiscard]] coroutine_handle<> arrive() noexcept {
const std::size_t oldCount = count_.fetch_sub(1, std::memory_order_acq_rel);
// Invalid to call arrive() if you haven't previously incremented the
......@@ -112,8 +112,8 @@ class Barrier {
bool await_ready() { return false; }
template <typename Promise>
std::experimental::coroutine_handle<> await_suspend(
std::experimental::coroutine_handle<Promise> continuation) noexcept {
coroutine_handle<> await_suspend(
coroutine_handle<Promise> continuation) noexcept {
if constexpr (detail::promiseHasAsyncFrame_v<Promise>) {
barrier_.setContinuation(
continuation, &continuation.promise().getAsyncFrame());
......@@ -140,7 +140,7 @@ class Barrier {
auto arriveAndWait() noexcept { return Awaiter{*this}; }
void setContinuation(
std::experimental::coroutine_handle<> continuation,
coroutine_handle<> continuation,
folly::AsyncStackFrame* parentFrame) noexcept {
assert(!continuation_);
continuation_ = continuation;
......@@ -149,7 +149,7 @@ class Barrier {
private:
std::atomic<std::size_t> count_;
std::experimental::coroutine_handle<> continuation_;
coroutine_handle<> continuation_;
folly::AsyncStackFrame* asyncFrame_ = nullptr;
};
......
......@@ -36,8 +36,8 @@ class BarrierTask {
struct FinalAwaiter {
bool await_ready() noexcept { return false; }
std::experimental::coroutine_handle<> await_suspend(
std::experimental::coroutine_handle<promise_type> h) noexcept {
coroutine_handle<> await_suspend(
coroutine_handle<promise_type> h) noexcept {
auto& promise = h.promise();
assert(promise.barrier_ != nullptr);
return promise.barrier_->arrive(promise.asyncFrame_);
......@@ -56,9 +56,7 @@ class BarrierTask {
}
BarrierTask get_return_object() noexcept {
return BarrierTask{
std::experimental::coroutine_handle<promise_type>::from_promise(
*this)};
return BarrierTask{coroutine_handle<promise_type>::from_promise(*this)};
}
suspend_always initial_suspend() noexcept { return {}; }
......@@ -88,7 +86,7 @@ class BarrierTask {
};
private:
using handle_t = std::experimental::coroutine_handle<promise_type>;
using handle_t = coroutine_handle<promise_type>;
explicit BarrierTask(handle_t coro) noexcept : coro_(coro) {}
......@@ -139,8 +137,7 @@ class DetachedBarrierTask {
DetachedBarrierTask get_return_object() noexcept {
return DetachedBarrierTask{
std::experimental::coroutine_handle<promise_type>::from_promise(
*this)};
coroutine_handle<promise_type>::from_promise(*this)};
}
suspend_always initial_suspend() noexcept { return {}; }
......@@ -148,8 +145,7 @@ class DetachedBarrierTask {
auto final_suspend() noexcept {
struct awaiter {
bool await_ready() noexcept { return false; }
auto await_suspend(
std::experimental::coroutine_handle<promise_type> h) noexcept {
auto await_suspend(coroutine_handle<promise_type> h) noexcept {
assert(h.promise().barrier_ != nullptr);
auto continuation =
h.promise().barrier_->arrive(h.promise().getAsyncFrame());
......@@ -181,7 +177,7 @@ class DetachedBarrierTask {
};
private:
using handle_t = std::experimental::coroutine_handle<promise_type>;
using handle_t = coroutine_handle<promise_type>;
explicit DetachedBarrierTask(handle_t coro) : coro_(coro) {}
......
......@@ -41,8 +41,7 @@ class CurrentAsyncStackFrameAwaitable {
bool await_ready() noexcept { return false; }
template <typename Promise>
bool await_suspend(
std::experimental::coroutine_handle<Promise> h) noexcept {
bool await_suspend(coroutine_handle<Promise> h) noexcept {
asyncFrame_ = &h.promise().getAsyncFrame();
return false;
}
......
......@@ -53,8 +53,7 @@ class InlineTaskPromiseBase {
bool await_ready() noexcept { return false; }
template <typename Promise>
std::experimental::coroutine_handle<> await_suspend(
std::experimental::coroutine_handle<Promise> h) noexcept {
coroutine_handle<> await_suspend(coroutine_handle<Promise> h) noexcept {
InlineTaskPromiseBase& promise = h.promise();
return promise.continuation_;
}
......@@ -83,14 +82,13 @@ class InlineTaskPromiseBase {
auto final_suspend() noexcept { return FinalAwaiter{}; }
void set_continuation(
std::experimental::coroutine_handle<> continuation) noexcept {
void set_continuation(coroutine_handle<> continuation) noexcept {
assert(!continuation_);
continuation_ = continuation;
}
private:
std::experimental::coroutine_handle<> continuation_;
coroutine_handle<> continuation_;
};
template <typename T>
......@@ -168,7 +166,7 @@ class InlineTask {
using promise_type = detail::InlineTaskPromise<T>;
private:
using handle_t = std::experimental::coroutine_handle<promise_type>;
using handle_t = coroutine_handle<promise_type>;
public:
InlineTask(InlineTask&& other) noexcept
......@@ -190,8 +188,7 @@ class InlineTask {
bool await_ready() noexcept { return false; }
handle_t await_suspend(
std::experimental::coroutine_handle<> awaitingCoroutine) noexcept {
handle_t await_suspend(coroutine_handle<> awaitingCoroutine) noexcept {
assert(coro_ && !coro_.done());
coro_.promise().set_continuation(awaitingCoroutine);
return coro_;
......@@ -223,13 +220,12 @@ class InlineTask {
template <typename T>
inline InlineTask<T> InlineTaskPromise<T>::get_return_object() noexcept {
return InlineTask<T>{
std::experimental::coroutine_handle<InlineTaskPromise<T>>::from_promise(
*this)};
coroutine_handle<InlineTaskPromise<T>>::from_promise(*this)};
}
inline InlineTask<void> InlineTaskPromise<void>::get_return_object() noexcept {
return InlineTask<void>{std::experimental::coroutine_handle<
InlineTaskPromise<void>>::from_promise(*this)};
return InlineTask<void>{
coroutine_handle<InlineTaskPromise<void>>::from_promise(*this)};
}
/// InlineTaskDetached is a coroutine-return type where the coroutine is
......@@ -248,8 +244,7 @@ struct InlineTaskDetached {
class promise_type {
struct FinalAwaiter {
bool await_ready() noexcept { return false; }
void await_suspend(
std::experimental::coroutine_handle<promise_type> h) noexcept {
void await_suspend(coroutine_handle<promise_type> h) noexcept {
folly::deactivateAsyncStackFrame(h.promise().getAsyncFrame());
h.destroy();
}
......@@ -271,8 +266,7 @@ struct InlineTaskDetached {
InlineTaskDetached get_return_object() noexcept {
return InlineTaskDetached{
std::experimental::coroutine_handle<promise_type>::from_promise(
*this)};
coroutine_handle<promise_type>::from_promise(*this)};
}
suspend_always initial_suspend() noexcept { return {}; }
......@@ -314,11 +308,10 @@ struct InlineTaskDetached {
}
private:
explicit InlineTaskDetached(
std::experimental::coroutine_handle<promise_type> h) noexcept
explicit InlineTaskDetached(coroutine_handle<promise_type> h) noexcept
: coro_(h) {}
std::experimental::coroutine_handle<promise_type> coro_;
coroutine_handle<promise_type> coro_;
};
} // namespace detail
......
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