diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2013-09-28 10:51:12 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2013-09-28 10:51:12 +0200 |
commit | 529b9704026fb7db8105f22dd5edbe6db1cdc706 (patch) | |
tree | 40877218bc3fcdf981f9e6fd63c79ddf138c8b28 /odb/mysql/section-statements.hxx | |
parent | e97e47cb1eeac5992d3316da9f005cc576a40611 (diff) |
Make schema version access (but not modification) thread-safe
Also cache the version in statements so that we don't have to lock
the mutex (slow) every time we need to check the version.
Diffstat (limited to 'odb/mysql/section-statements.hxx')
-rw-r--r-- | odb/mysql/section-statements.hxx | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/odb/mysql/section-statements.hxx b/odb/mysql/section-statements.hxx index 2e01df4..bc83942 100644 --- a/odb/mysql/section-statements.hxx +++ b/odb/mysql/section-statements.hxx @@ -10,12 +10,15 @@ #include <cstddef> // std::size_t #include <odb/forward.hxx> +#include <odb/schema-version.hxx> #include <odb/traits.hxx> #include <odb/mysql/version.hxx> #include <odb/mysql/mysql.hxx> #include <odb/mysql/binding.hxx> #include <odb/mysql/statement.hxx> +#include <odb/mysql/connection.hxx> +#include <odb/mysql/database.hxx> #include <odb/mysql/details/export.hxx> namespace odb @@ -46,6 +49,15 @@ namespace odb connection_type& connection () {return conn_;} + const schema_version_migration& + version_migration (const char* name = "") const + { + if (svm_ == 0) + svm_ = &conn_.database ().schema_version_migration (name); + + return *svm_; + } + image_type& image () {return image_;} @@ -140,6 +152,7 @@ namespace odb protected: connection_type& conn_; + mutable const schema_version_migration* svm_; // These come from object_statements. // |