[core] move SharedSQLiteCache::get to SQLiteCache::getShared

This commit is contained in:
Konstantin Käfer
2016-01-14 15:02:14 +01:00
parent f62d41ae05
commit 8939a7b706
3 changed files with 5 additions and 12 deletions

View File

@@ -22,7 +22,7 @@ class DefaultFileSource::Impl {
public:
Impl(const std::string& cachePath, const std::string& assetRoot)
: assetFileSource(assetRoot),
cache(SharedSQLiteCache::get(cachePath)),
cache(SQLiteCache::getShared(cachePath)),
onlineFileSource(cache.get()) {
}

View File

@@ -472,7 +472,7 @@ void SQLiteCache::Impl::refresh(const Resource& resource, Seconds expires) {
}
}
std::shared_ptr<SQLiteCache> SharedSQLiteCache::get(const std::string &path) {
std::shared_ptr<SQLiteCache> SQLiteCache::getShared(const std::string &path) {
std::shared_ptr<SQLiteCache> temp = masterPtr.lock();
if (!temp) {
temp.reset(new SQLiteCache(path));
@@ -482,6 +482,6 @@ std::shared_ptr<SQLiteCache> SharedSQLiteCache::get(const std::string &path) {
return temp;
}
std::weak_ptr<SQLiteCache> SharedSQLiteCache::masterPtr;
std::weak_ptr<SQLiteCache> SQLiteCache::masterPtr;
} // namespace mbgl

View File

@@ -20,6 +20,8 @@ template <typename T> class Thread;
class SQLiteCache : private util::noncopyable {
public:
static std::shared_ptr<SQLiteCache> getShared(const std::string &path = ":memory:");
SQLiteCache(const std::string &path = ":memory:");
~SQLiteCache();
@@ -35,15 +37,6 @@ public:
private:
const std::unique_ptr<util::Thread<Impl>> thread;
};
class SharedSQLiteCache : util::noncopyable {
public:
static std::shared_ptr<SQLiteCache> get(const std::string &path = ":memory:");
private:
SharedSQLiteCache() {}
static std::weak_ptr<SQLiteCache> masterPtr;
};