I would like to turn the CassFuture Object from Datastax's C++ Driver to a Boost Asio Awaitable Object. The problem is it seems like this conversion could induce additional overhead as I would effectively be wrapping a future around another future. Does anyone have any smart ideas or useful insights or worst case a way to approach this that minimally wastes computational effort?
I have considered the idea of creating a for loop where when it checks the future and the future yields no result (ie. no error or result) that it simply passes priority back to the io_context, but this seems inefficient and arbitrary versus leaving and the scheduling to the built in io_context scheduler.
You could use the callback handler. From the linked page:
I have not delved into the documentation to find out exactly which threads could invoke the callback. If you want to completely isolate from the implementation detail, you could always post a handler onto the Asio service.
To be completely Asio compatible (including
asio::use_future
,asio::use_awaitable
etc), you could implement an async initiation function using the Completion Token pattern.