diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2011-08-24 13:42:04 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2011-08-24 13:42:04 +0200 |
commit | 1d42e7cc891403b5f20eb67bc08f23a667019402 (patch) | |
tree | 8cad3b525097d47b933e5f10c11ed83c6d661895 /odb/tracer/transaction-impl.cxx | |
parent | 148e68c83c45bb374785306476351181e00f0a09 (diff) |
Add support for transaction multiplexing
Also delay getting a connection until after we do all the sanity
checks (e.g., that there is no active transaction). Otherwise we
are running risk of getting blocked rather than throwing an
exception.
Diffstat (limited to 'odb/tracer/transaction-impl.cxx')
-rw-r--r-- | odb/tracer/transaction-impl.cxx | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/odb/tracer/transaction-impl.cxx b/odb/tracer/transaction-impl.cxx index 2069568..bf272b3 100644 --- a/odb/tracer/transaction-impl.cxx +++ b/odb/tracer/transaction-impl.cxx @@ -17,12 +17,17 @@ namespace odb namespace tracer { transaction_impl:: + transaction_impl (database_type& db) + : odb::transaction_impl (db), finalized_ (false) + { + } + + transaction_impl:: transaction_impl (connection_ptr c) : odb::transaction_impl (c->database (), *c), finalized_ (false), connection_ (c) { - cout << "begin transaction" << endl; } transaction_impl:: @@ -33,6 +38,20 @@ namespace odb } void transaction_impl:: + start () + { + // Grab a connection if we don't already have one. + // + if (connection_ == 0) + { + connection_ = static_cast<database_type&> (database_).connection (); + odb::transaction_impl::connection_ = connection_.get (); + } + + cout << "begin transaction" << endl; + } + + void transaction_impl:: commit () { cout << "commit transaction" << endl; |