From f3c2093502389da1feacd41bfd20f32d2e84fb66 Mon Sep 17 00:00:00 2001 From: Mike Morris Date: Fri, 17 Apr 2015 18:04:31 +0200 Subject: [PATCH 1/2] emplace into threadSet Map thread and Main thread should be separated in Mode::Static now --- src/mbgl/map/environment.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/mbgl/map/environment.cpp b/src/mbgl/map/environment.cpp index d121f9655..f2112c61b 100644 --- a/src/mbgl/map/environment.cpp +++ b/src/mbgl/map/environment.cpp @@ -36,10 +36,7 @@ public: void registerThread(Environment* env, ThreadType type, const std::string& name) { std::lock_guard lock(mtx); - // FIXME: We should never need to overwrite a thread here and we only allow - // this today because on the Static mode, the Map thread and the Main thread - // are same. Replace this with emplace() when this gets fixed. - threadSet[std::this_thread::get_id()] = ThreadInfo{ env, type, name }; + threadSet.emplace(std::this_thread::get_id(), ThreadInfo{ env, type, name }); } void unregisterThread() { From b162fb7c6f8eb863334d3f9488716c0b1cd9c623 Mon Sep 17 00:00:00 2001 From: "Thiago Marcos P. Santos" Date: Fri, 15 May 2015 13:05:58 +0300 Subject: [PATCH 2/2] Make the MapContext object run on its own thread on the tests The MapContext can only run on its own thread because it is registering a EnvironmentScope and it is making many assertions on Debug mode if its methods are being called on the Map thread. --- test/miscellaneous/map_context.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/test/miscellaneous/map_context.cpp b/test/miscellaneous/map_context.cpp index 0b465aa3c..95fbf7b9a 100644 --- a/test/miscellaneous/map_context.cpp +++ b/test/miscellaneous/map_context.cpp @@ -1,22 +1,24 @@ #include "../fixtures/util.hpp" -#include #include #include #include #include #include +#include using namespace mbgl; TEST(MapContext, DoubleStyleLoad) { - util::RunLoop runLoop(uv_default_loop()); std::shared_ptr display = std::make_shared(); HeadlessView view(display, 512, 512, 1); DefaultFileSource fileSource(nullptr); MapData data(view, MapMode::Continuous); - MapContext context(uv_default_loop(), view, fileSource, data); - context.setStyleJSON("", ""); - context.setStyleJSON("", ""); + std::unique_ptr> context( + util::make_unique>( + "Map", util::ThreadPriority::Regular, view, fileSource, data)); + + context->invokeSync(&MapContext::setStyleJSON, "", ""); + context->invokeSync(&MapContext::setStyleJSON, "", ""); }