Make co_awaitTry(AsyncGenerator) return Try<NextResult<T>>
Summary: There are two problems with the current approach of returning Try<T>: - It is impossible to write generic algorithms like coro::timeout that convert any awaitable into a Task of its await result without throwing exceptions because there's no way to reconstruct the expected return type. More generally, we want the property that the await_try_result_t::element_type matches the await_result_t so we can make drop-in replacements by wrapping in functions like timeout. - There's no way to both avoid moving yielded values and avoid throwing exceptions because Try doesn't support references (and an earlier diff adding this support was rejected), which means the two performance optimizations avaioable to users of AsyncGenerator are mutually exclusive We fix this to restore the aforementioned invariant by wrapping the existing result type. This is a marginal inefficiency, so if we notice regressions as a result we can specialize these Try instantiations to consolidate the storage. For now we do not except this to matter. Reviewed By: andriigrynenko Differential Revision: D29680441 fbshipit-source-id: 4ef74f4645d990b623bb95a297718fb576a9b977
Showing
Please register or sign in to comment