Merge branch 'master' of github.com:mapbox/mapbox-gl-native into android-mason

Conflicts:
	include/mbgl/storage/base_request.hpp
	include/mbgl/storage/file_request_baton.hpp
	include/mbgl/storage/http_request.hpp
	include/mbgl/storage/http_request_baton.hpp
	include/mbgl/util/uv_detail.hpp
	platform/darwin/http_request_baton_cocoa.mm
	platform/default/caching_http_file_source.cpp
	platform/default/http_request_baton_curl.cpp
	src/map/map.cpp
	src/storage/base_request.cpp
	src/storage/file_request.cpp
	src/storage/file_request_baton.cpp
	src/storage/http_request.cpp
	src/storage/http_request_baton.cpp
This commit is contained in:
Leith Bade
2014-12-04 22:19:46 +11:00
21 changed files with 135 additions and 145 deletions

View File

@@ -10,27 +10,13 @@
namespace mbgl {
CachingHTTPFileSource::CachingHTTPFileSource(uv_loop_t* loop_, const std::string &path_)
: thread_id(uv_thread_self()),
path(path_),
store(!path.empty() ? util::ptr<SQLiteStore>(new SQLiteStore(loop_, path)) : nullptr),
loop(loop_),
queue(new uv_messenger_t) {
uv_messenger_init(loop, queue, [](void *ptr) {
std::unique_ptr<std::function<void()>> fn { reinterpret_cast<std::function<void()> *>(ptr) };
(*fn)();
});
uv_unref((uv_handle_t *)&queue->async);
}
CachingHTTPFileSource::CachingHTTPFileSource(const std::string &path_)
: path(path_) {}
CachingHTTPFileSource::~CachingHTTPFileSource() {
if (hasLoop()) {
// FIXME temp fix for #608 crash
// assert(thread_id == uv_thread_self());
// assert(thread_id == std::this_thread::get_id());
uv_messenger_stop(queue, [](uv_messenger_t *msgr) {
delete msgr;
});
@@ -47,7 +33,7 @@ CachingHTTPFileSource::~CachingHTTPFileSource() {
}
void CachingHTTPFileSource::setLoop(uv_loop_t* loop_) {
thread_id = uv_thread_self();
thread_id = std::this_thread::get_id();
store = !path.empty() ? util::ptr<SQLiteStore>(new SQLiteStore(loop_, path)) : nullptr;
loop = loop_;
queue = new uv_messenger_t;
@@ -64,17 +50,17 @@ bool CachingHTTPFileSource::hasLoop() {
}
void CachingHTTPFileSource::setBase(const std::string &value) {
assert(thread_id == uv_thread_self());
assert(thread_id == std::this_thread::get_id());
base = value;
}
const std::string &CachingHTTPFileSource::getBase() const {
assert(thread_id == uv_thread_self());
assert(thread_id == std::this_thread::get_id());
return base;
}
std::unique_ptr<Request> CachingHTTPFileSource::request(ResourceType type, const std::string &url) {
assert(thread_id == uv_thread_self());
assert(thread_id == std::this_thread::get_id());
// Make URL absolute.
const std::string absoluteURL = [&]() -> std::string {
@@ -111,7 +97,7 @@ std::unique_ptr<Request> CachingHTTPFileSource::request(ResourceType type, const
}
void CachingHTTPFileSource::prepare(std::function<void()> fn) {
if (thread_id == uv_thread_self()) {
if (thread_id == std::this_thread::get_id()) {
fn();
} else {
uv_messenger_send(queue, new std::function<void()>(std::move(fn)));
@@ -119,7 +105,7 @@ void CachingHTTPFileSource::prepare(std::function<void()> fn) {
}
void CachingHTTPFileSource::retryAllPending() {
assert(thread_id == uv_thread_self());
assert(thread_id == std::this_thread::get_id());
util::ptr<BaseRequest> req;
for (const std::pair<std::string, std::weak_ptr<BaseRequest>> &pair : pending) {