aboutsummaryrefslogtreecommitdiff
path: root/odb/sqlite/connection-factory.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2011-03-29 16:31:59 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2011-03-29 16:31:59 +0200
commit7aadac132d8512e7ee63970561f40ade80772726 (patch)
tree001695ad14cd9c2e6937a8e5d45a32587d0a37d5 /odb/sqlite/connection-factory.cxx
parent2cdc08a9bcf807b4b908434c7bbe5439b0da3191 (diff)
Support for shared cache and unlock notification
Diffstat (limited to 'odb/sqlite/connection-factory.cxx')
-rw-r--r--odb/sqlite/connection-factory.cxx24
1 files changed, 19 insertions, 5 deletions
diff --git a/odb/sqlite/connection-factory.cxx b/odb/sqlite/connection-factory.cxx
index 4cae67f..11184bc 100644
--- a/odb/sqlite/connection-factory.cxx
+++ b/odb/sqlite/connection-factory.cxx
@@ -5,6 +5,7 @@
#include <odb/details/lock.hxx>
+#include <odb/sqlite/database.hxx>
#include <odb/sqlite/connection-factory.hxx>
using namespace std;
@@ -31,13 +32,19 @@ namespace odb
shared_ptr<connection> new_connection_factory::
connect ()
{
- return shared_ptr<connection> (new (shared) connection (*db_));
+ return shared_ptr<connection> (
+ new (shared) connection (*db_, extra_flags_));
}
void new_connection_factory::
database (database_type& db)
{
db_ = &db;
+
+ // Unless explicitly disabled, enable shared cache.
+ //
+ if ((db_->flags () & SQLITE_OPEN_PRIVATECACHE) == 0)
+ extra_flags_ |= SQLITE_OPEN_SHAREDCACHE;
}
//
@@ -82,7 +89,7 @@ namespace odb
if(max_ == 0 || in_use_ < max_)
{
shared_ptr<pooled_connection> c (
- new (shared) pooled_connection (*db_, this));
+ new (shared) pooled_connection (*db_, extra_flags_, this));
in_use_++;
return c;
}
@@ -100,6 +107,11 @@ namespace odb
{
db_ = &db;
+ // Unless explicitly disabled, enable shared cache.
+ //
+ if ((db_->flags () & SQLITE_OPEN_PRIVATECACHE) == 0)
+ extra_flags_ |= SQLITE_OPEN_SHAREDCACHE;
+
if (min_ > 0)
{
connections_.reserve (min_);
@@ -108,7 +120,7 @@ namespace odb
{
connections_.push_back (
shared_ptr<pooled_connection> (
- new (shared) pooled_connection (*db_, 0)));
+ new (shared) pooled_connection (*db_, extra_flags_, 0)));
}
}
}
@@ -143,8 +155,10 @@ namespace odb
//
connection_pool_factory::pooled_connection::
- pooled_connection (database_type& db, connection_pool_factory* pool)
- : connection (db), pool_ (pool)
+ pooled_connection (database_type& db,
+ int extra_flags,
+ connection_pool_factory* pool)
+ : connection (db, extra_flags), pool_ (pool)
{
callback_.arg = this;
callback_.zero_counter = &zero_counter;