[core] move SharedSQLiteCache::get to SQLiteCache::getShared
This commit is contained in:
@@ -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()) {
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user