diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2012-04-26 16:45:23 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2012-04-26 16:45:23 +0200 |
commit | 33c8b712edde86572443a0200169262240d2d974 (patch) | |
tree | a13233c5af8d44d7678e3aecad05a47b6b83ed2d /odb/transaction.cxx | |
parent | 3067453a4c623c364286e7d68a446ce15e00b397 (diff) |
Add database::reset()
Diffstat (limited to 'odb/transaction.cxx')
-rw-r--r-- | odb/transaction.cxx | 35 |
1 files changed, 16 insertions, 19 deletions
diff --git a/odb/transaction.cxx b/odb/transaction.cxx index 9099b57..6f92c41 100644 --- a/odb/transaction.cxx +++ b/odb/transaction.cxx @@ -18,35 +18,32 @@ namespace odb static ODB_TLS_POINTER (transaction) current_transaction; transaction:: - transaction (transaction_impl* impl, bool make_current) - : finalized_ (false), impl_ (impl) + ~transaction () + { + if (!finalized_) + try {rollback ();} catch (...) {} + } + + void transaction:: + reset (transaction_impl* impl, bool make_current) { + details::unique_ptr<transaction_impl> i (impl); + + if (!finalized_) + rollback (); + + impl_.reset (i.release ()); + if (make_current && tls_get (current_transaction) != 0) throw already_in_transaction (); impl_->start (); + finalized_ = false; if (make_current) tls_set (current_transaction, this); } - transaction:: - ~transaction () - { - if (!finalized_) - { - try - { - rollback (); - } - catch (...) - { - } - } - - delete impl_; - } - bool transaction:: has_current () { |