JhonJun Dormitorio via asio-users
2017-06-06 03:34:34 UTC
Hi,
I would like to create an asynchronous C++ binding for PostgreSQL. Their libpq has some very minimal and rudimentary async support:
https://www.postgresql.org/docs/9.5/static/libpq-async.html
The following is an example of how they call the operations asynchronously:
https://www.postgresql.org/docs/9.5/static/libpq-example.html#LIBPQ-EXAMPLE-2
In this example, they use select to wait for incoming packets. I'm thinking, there must be a better way and use Asio's abstraction to implement this async support. I tried looking into Asio's code but it is currently beyond me.
May I know what is the best way to approach this problem? Should I inherit from boost::asio::ip::tcp::socket or something? How would I know that data has arrived so I can call the completion handler? What is the recommended approach in terms of memory allocation if I want to iterate over all the rows that has been returned from a select statement for example?
Thanks in advance!Jhonjun
I would like to create an asynchronous C++ binding for PostgreSQL. Their libpq has some very minimal and rudimentary async support:
https://www.postgresql.org/docs/9.5/static/libpq-async.html
The following is an example of how they call the operations asynchronously:
https://www.postgresql.org/docs/9.5/static/libpq-example.html#LIBPQ-EXAMPLE-2
In this example, they use select to wait for incoming packets. I'm thinking, there must be a better way and use Asio's abstraction to implement this async support. I tried looking into Asio's code but it is currently beyond me.
May I know what is the best way to approach this problem? Should I inherit from boost::asio::ip::tcp::socket or something? How would I know that data has arrived so I can call the completion handler? What is the recommended approach in terms of memory allocation if I want to iterate over all the rows that has been returned from a select statement for example?
Thanks in advance!Jhonjun