yandex / ozo

OZO is a C++17 Boost.Asio based header-only library for asyncronous communication with PostgreSQL DBMS.
PostgreSQL License
226 stars 45 forks source link

c++20 coroutine compatibility #308

Closed cyboy22 closed 1 year ago

cyboy22 commented 1 year ago

Hi - I intend to use a Boost Redis (which leverages the c++20 coroutine functionality) for my cache and would like to use OZO for interacting with my PostgreSQL database. Are there any compatibility (or incompatibility) issues from a coroutine implementation perspective?

cyboy22 commented 1 year ago

The Boost Redis API uses "co_spawn" whereas I understand OZO uses "spawn" under the hood but appears to work with the following syntax:

        const auto selectConnection =  co_await ozo::request(conn_info[ios],
                                                             selectQuery,
                                                             1s,
                                                             ozo::into(selectQueryResult),
                                                             use_awaitable);
thed636 commented 1 year ago

Hi! OZO uses no spawn or other stackless/stackful natural coroutine mechanisms under the hood (except boost::asio::coroutine, which is not a coroutine in nature). The library uses universal asynchronous API and is compatible with all the completion tokens from Boost.Asio.