Commit 40b160ef authored by Yedidya Feldblum's avatar Yedidya Feldblum Committed by Facebook GitHub Bot

add missing co-invoke to async-generator safe-point test

Summary: The `AsyncGenerator` test for `co_safe_point` immediately-invokes a temporary coroutine function to return a coroutine object, but the temporary coroutine function goes out of scope while the returned coroutine is live. Use `co_invoke` to fix it.

Reviewed By: lxfind

Differential Revision: D26408345

fbshipit-source-id: 4650ea57c01baffb1065560b661e3296cb0292cc
parent 229610b6
......@@ -610,17 +610,18 @@ TEST(AsyncGenerator, SafePoint) {
step_type step = step_type::init;
folly::CancellationSource cancelSrc;
auto gen = [&]() -> folly::coro::AsyncGenerator<int> {
step = step_type::before_continue_sp;
co_await folly::coro::co_safe_point;
step = step_type::after_continue_sp;
auto gen =
folly::coro::co_invoke([&]() -> folly::coro::AsyncGenerator<int> {
step = step_type::before_continue_sp;
co_await folly::coro::co_safe_point;
step = step_type::after_continue_sp;
cancelSrc.requestCancellation();
cancelSrc.requestCancellation();
step = step_type::before_cancel_sp;
co_await folly::coro::co_safe_point;
step = step_type::after_cancel_sp;
}();
step = step_type::before_cancel_sp;
co_await folly::coro::co_safe_point;
step = step_type::after_cancel_sp;
});
auto result = co_await folly::coro::co_awaitTry(
folly::coro::co_withCancellation(cancelSrc.getToken(), gen.next()));
......
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