Discussion:
How to hook with the Proactor when writing a custom IO Object
(too old to reply)
JhonJun Dormitorio via asio-users
2017-06-06 03:34:34 UTC
Permalink
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
Boris Schäling
2017-06-16 10:23:05 UTC
Permalink
Post by JhonJun Dormitorio via asio-users
Hi,
I would like to create an asynchronous C++ binding for PostgreSQL. Their
libpq has some very minimal and rudimentary
[...]
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?
It's a while ago but I once gave a presentation on how to create Boost.Asio
extensions (like your own I/O objects). Here are the slides:
https://github.com/boostcon/2011_presentations/raw/master/wed/creating_boost_asio_extensions.pdf

The presentation was recorded although I'm not sure whether the video and
audio quality is good enough. The video should be somewhere on Youtube if
you are interested.

HTH,
Boris



------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
asio-users mailing list
asio-***@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/asio-users
_______________________________________________
Using Asio? List your project at
http://think-async.com/Asio/WhoIsUsingAsio

Loading...