diff options
author | Konstantin Käfer <mail@kkaefer.com> | 2014-04-25 14:26:59 +0200 |
---|---|---|
committer | Konstantin Käfer <mail@kkaefer.com> | 2014-04-25 14:26:59 +0200 |
commit | 666f593803d29ff88173714e373a35886b51efe1 (patch) | |
tree | 8b2671142d865099e9f15d9d9a87b321f8ef92dd /common/curl_request.cpp | |
parent | a0d935eac7b9e9c68653140cee3a2b8a0600fceb (diff) | |
download | qtlocation-mapboxgl-666f593803d29ff88173714e373a35886b51efe1.tar.gz |
use an event loop per map that is not the render thread
Diffstat (limited to 'common/curl_request.cpp')
-rw-r--r-- | common/curl_request.cpp | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/common/curl_request.cpp b/common/curl_request.cpp index cca50447f4..e00e805786 100644 --- a/common/curl_request.cpp +++ b/common/curl_request.cpp @@ -88,9 +88,10 @@ static std::queue<CURL *> curl_handle_cache; class CURLRequest : public llmr::platform::Request { public: CURLRequest(const std::string &url, - std::function<void(llmr::platform::Response *)> background_function, - std::function<void()> foreground_callback) - : Request(url, background_function, foreground_callback) {} + std::function<void(llmr::platform::Response *)> background_function, + std::function<void()> foreground_callback, + uv_loop_t *loop) + : Request(url, background_function, foreground_callback, loop) {} CURL *curl = nullptr; }; @@ -177,7 +178,7 @@ void curl_perform(uv_poll_t *req, int /*status*/, int events) { // Executes the background_function in a libuv thread pool, and the after_work_cb back // in the *main* event loop. - uv_queue_work(uv_default_loop(), work, Request::work_callback, Request::after_work_callback); + uv_queue_work((*req)->loop, work, Request::work_callback, Request::after_work_callback); CURL *handle = message->easy_handle; remove_curl_handle(handle); @@ -367,10 +368,11 @@ void thread_init_cb() { std::shared_ptr<platform::Request> platform::request_http(const std::string &url, std::function<void(Response *)> background_function, - std::function<void()> foreground_callback) { + std::function<void()> foreground_callback, + uv_loop_t *loop) { using namespace request; init_thread_once(thread_init_cb); - std::shared_ptr<CURLRequest> req = std::make_shared<CURLRequest>(url, background_function, foreground_callback); + std::shared_ptr<CURLRequest> req = std::make_shared<CURLRequest>(url, background_function, foreground_callback, loop); // Note that we are creating a new shared_ptr pointer(!) because the lockless queue can't store // objects with nontrivial destructors. We have to make absolutely sure that we manually delete |