-
Notifications
You must be signed in to change notification settings - Fork 48
Description
I've been having a lot of ... fun implementing boost::asio
alongside this lib - mainly due to the fact that the ASIO coroutine co_await
handler looks like this
// Support for co_await keyword.
template <class U>
void await_suspend(
detail::coroutine_handle<detail::awaitable_frame<U, Executor>> h)
{
frame_->push_frame(&h.promise());
}
Obviously, once cppgraphqlgen's resolve
function has been entered, all the context needed for filling out the std::coroutine_handle<detail::awaitable_frame<U, Executor>>
disappears, and is replaced with graphql::service::AwaitableObject<#value>::promise_type
My not-really-ideal workaround has been
- Enter the GraphQL system from a
boost::asio::awaitable
context - Drop into the cppgraphqlgen
resolve
context, lose my immediateboost::asio
context and have all functions returnstd::future<T>
to fullfill thegraphql::service::AwaitableObject
- Use
boost::asio:co_spawn
to restart theboost::asio::awaitable
contexts and return futures viaboost::asio::use_future
I'm curious that due to the fact that boost::asio::awaitable
's context is basically the internal guts for its actual coroutine-execution-operation-element-bits, are there any other good examples for async-execution frameworks/libraries that can be used with this library and don't require modifying that underlying service::Awaitable
type to be aware of how the async library works?
I suppose for comparison, I'm thinking of C libraries which do a sync version of their calls, then specialise for libuv
, libevent
etc - I am really hoping that C++ coroutines give us some means of abstracting the libuv
-equivalent away, but given my experience so far, I'm guessing maybe it can't.