Merge pull request #1291 from mapbox/threadset-emplace

emplace into threadSet
This commit is contained in:
Thiago Marcos P. Santos
2015-05-15 13:22:59 +03:00
2 changed files with 8 additions and 9 deletions

View File

@@ -36,10 +36,7 @@ public:
void registerThread(Environment* env, ThreadType type, const std::string& name) {
std::lock_guard<std::mutex> 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() {

View File

@@ -1,22 +1,24 @@
#include "../fixtures/util.hpp"
#include <mbgl/util/run_loop.hpp>
#include <mbgl/map/map_data.hpp>
#include <mbgl/map/map_context.hpp>
#include <mbgl/platform/default/headless_view.hpp>
#include <mbgl/platform/default/headless_display.hpp>
#include <mbgl/storage/default_file_source.hpp>
#include <mbgl/util/thread.hpp>
using namespace mbgl;
TEST(MapContext, DoubleStyleLoad) {
util::RunLoop runLoop(uv_default_loop());
std::shared_ptr<HeadlessDisplay> display = std::make_shared<HeadlessDisplay>();
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<util::Thread<MapContext>> context(
util::make_unique<util::Thread<MapContext>>(
"Map", util::ThreadPriority::Regular, view, fileSource, data));
context->invokeSync(&MapContext::setStyleJSON, "", "");
context->invokeSync(&MapContext::setStyleJSON, "", "");
}