diff options
Diffstat (limited to 'platform/default/caching_http_file_source.cpp')
-rw-r--r-- | platform/default/caching_http_file_source.cpp | 28 |
1 files changed, 7 insertions, 21 deletions
diff --git a/platform/default/caching_http_file_source.cpp b/platform/default/caching_http_file_source.cpp index b7cbb268f4..20525a2647 100644 --- a/platform/default/caching_http_file_source.cpp +++ b/platform/default/caching_http_file_source.cpp @@ -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) { |