[core] default file source - ensure thread safety for cached values

This commit is contained in:
Ivo van Dongen
2017-05-26 18:40:49 +03:00
committed by Ivo van Dongen
parent 89129379f1
commit 5cf0fc0f8b
2 changed files with 21 additions and 6 deletions

View File

@@ -5,6 +5,7 @@
#include <mbgl/util/constants.hpp>
#include <vector>
#include <mutex>
namespace mbgl {
@@ -34,10 +35,10 @@ public:
}
void setAPIBaseURL(const std::string&);
std::string getAPIBaseURL() const;
std::string getAPIBaseURL();
void setAccessToken(const std::string&);
std::string getAccessToken() const;
std::string getAccessToken();
void setResourceTransform(std::function<std::string(Resource::Kind, std::string&&)>);
@@ -143,7 +144,11 @@ private:
// Shared so destruction is done on this thread
const std::shared_ptr<FileSource> assetFileSource;
const std::unique_ptr<util::Thread<Impl>> thread;
std::mutex cachedBaseURLMutex;
std::string cachedBaseURL = mbgl::util::API_BASE_URL;
std::mutex cachedAccessTokenMutex;
std::string cachedAccessToken;
};