Add CoInvoke() GMock helper for writing safe coroutine lambda versions
Summary: Adds a new CoInvoke() helper function that should be used instead of ::testing::Invoke() when defining mock methods using coroutine lambdas. Use of Invoke() in a GMock definition that calls a coroutine-lambda that contains captures will result in the returned Task holding a dangling reference to a copy of the lambda. The CoInvoke() helper instead, ensures that the coroutine created by the lambda holds on to a reference to a copy of the lambda that is kept alive until the coroutine completes by invoking the lambda using the folly::coro::co_invoke() utility function instead of directly calling operator(). Reviewed By: andriigrynenko Differential Revision: D21578404 fbshipit-source-id: 3322740efd00596c2311530a166ef2d5301c6b89
Showing
Please register or sign in to comment