diff options
author | John Firebaugh <john.firebaugh@gmail.com> | 2014-11-27 15:10:49 -0800 |
---|---|---|
committer | John Firebaugh <john.firebaugh@gmail.com> | 2014-12-02 12:24:25 -0800 |
commit | 8f1772f18fe4ca74d66d351e3da2bf81b94c0330 (patch) | |
tree | fe09da030b641f13607474fb19ed1a46db2a4719 /src | |
parent | 9e819a4cbea3456f3293fdad4354d36e67d1cf22 (diff) | |
download | qtlocation-mapboxgl-8f1772f18fe4ca74d66d351e3da2bf81b94c0330.tar.gz |
More complete uv::thread
Diffstat (limited to 'src')
-rw-r--r-- | src/map/map.cpp | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/src/map/map.cpp b/src/map/map.cpp index 42e7a7dcff..4e588943da 100644 --- a/src/map/map.cpp +++ b/src/map/map.cpp @@ -87,7 +87,6 @@ using namespace mbgl; Map::Map(View& view_) : loop(std::make_unique<uv::loop>()), - thread(std::make_unique<uv::thread>()), view(view_), #ifndef NDEBUG main_thread(uv_thread_self()), @@ -180,23 +179,25 @@ void Map::start() { painter.cleanup(); }); - uv_thread_create(*thread, [](void *arg) { - Map *map = static_cast<Map *>(arg); + thread = std::make_unique<uv::thread>([this]() { #ifndef NDEBUG - map->map_thread = uv_thread_self(); + map_thread = uv_thread_self(); #endif + #ifdef __APPLE__ pthread_setname_np("Map"); #endif - map->run(); + + run(); + #ifndef NDEBUG - map->map_thread = -1; + map_thread = -1; #endif // Make sure that the stop() function knows when to stop invoking the callback function. - map->is_stopped = true; - map->view.notify(); - }, this); + is_stopped = true; + view.notify(); + }); } void Map::stop(stop_callback cb, void *data) { @@ -220,7 +221,7 @@ void Map::stop(stop_callback cb, void *data) { // If a callback function was provided, this should return immediately because the thread has // already finished executing. - uv_thread_join(*thread); + thread->join(); async = false; } |