[Libpqxx-general] Connection Pool
Manuel Argüelles
manuel.arguelles at gmail.com
Tue Jul 14 14:43:53 UTC 2009
Thanks a lot Jeroen :)
> On Tue, July 14, 2009 01:01, Manuel Argüelles wrote:
> > I'm looking forward to build a connection pool class, do you know if
> > there's
> > any example code or similar that may help me?, if possible I'll like it
> > to be
> > multi thread-safe.
>
> Nice! There's an example that might be of use on Launchpad:
>
> https://code.launchpad.net/~jtv/libpqxx/connection-pool
>
> That's just a sketch thoughno testing, and I don't think I got the BOOST
> thread synchronization right. It's also a bit experimental in that it
> uses the shared_ptr destructor to hand back a connection to the pool when
> the thread that held it destroys its last reference to the connection.
>
> > So far what I have thought is to create n lazy connection objects, the
> > problem comes in how to know which connection is free (to assign the
> > transaction to) and dealing with connection errors.
>
> You could keep track of that separately.
>
> > Or do you think it will be enough to have an static counter of the
> > connections
> > and just assign the transactions to the next one (as in a loop)?
>
> No, because you still won't know whether the last thread that held a
> connection is done with it!
>
>
> Jeroen
More information about the Libpqxx-general
mailing list