From 29f048816a31422685c44085ac20e45d97f95ecf Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Sat, 28 Sep 2013 10:51:12 +0200 Subject: 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. --- odb/sqlite/section-statements.hxx | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'odb/sqlite/section-statements.hxx') diff --git a/odb/sqlite/section-statements.hxx b/odb/sqlite/section-statements.hxx index 8bdbda1..dff5ec5 100644 --- a/odb/sqlite/section-statements.hxx +++ b/odb/sqlite/section-statements.hxx @@ -10,12 +10,15 @@ #include // std::size_t #include +#include #include #include #include #include #include +#include +#include #include 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_;} @@ -138,6 +150,7 @@ namespace odb protected: connection_type& conn_; + mutable const schema_version_migration* svm_; // These come from object_statements. // -- cgit v1.1