[odb-users] safe usage odb connection pool in multi threaded environment (odb 2.4.0)

Boris Kolpackov boris at codesynthesis.com
Tue May 2 09:05:56 EDT 2017


Пустовалов Дмитрий <pustovalovdmit at gmail.com> writes:

> Am I understand right that I should pass odb::database between the threads
> and when I begin transaction on some thread passing to odb::transaction
> return value from odb::database::begin I ensure that this transaction will
> work on other database connection if needed?

When you call database::begin() it gets the connection from the pool and
returns it together with the transaction object. Once you finalize the
transaction (e.g., commit or roll it back, or let it go out of scope in
which case it is rolled back automatically), then the connection is
automatically returned back into the pool.


More information about the odb-users mailing list