From 817c26111a0d6650e7ebae73e46621626106d0a7 Mon Sep 17 00:00:00 2001 From: Mike Morris Date: Wed, 12 Oct 2016 17:28:22 -0400 Subject: [core] [node] pass thread pool impl to Map constructor Updates mbgl::Map constructor usage everywhere Adds NodeThreadPool implementation using AsyncQueue to call Nan::AsyncQueueWorker from main thread --- test/api/annotations.test.cpp | 4 +++- test/api/api_misuse.test.cpp | 7 +++++-- test/api/custom_layer.test.cpp | 5 ++++- test/api/query.test.cpp | 4 +++- test/api/render_missing.test.cpp | 7 +++++-- test/api/repeated_render.test.cpp | 8 ++++++-- 6 files changed, 26 insertions(+), 9 deletions(-) (limited to 'test/api') diff --git a/test/api/annotations.test.cpp b/test/api/annotations.test.cpp index 6d6734a10f..c1716a5228 100644 --- a/test/api/annotations.test.cpp +++ b/test/api/annotations.test.cpp @@ -1,6 +1,7 @@ #include #include +#include #include #include #include @@ -25,7 +26,8 @@ public: std::shared_ptr display { std::make_shared() }; HeadlessView view { display, 1 }; StubFileSource fileSource; - Map map { view, fileSource, MapMode::Still }; + ThreadPool threadPool { 4 }; + Map map { view, fileSource, threadPool, MapMode::Still }; void checkRendering(const char * name) { test::checkImage(std::string("test/fixtures/annotations/") + name, diff --git a/test/api/api_misuse.test.cpp b/test/api/api_misuse.test.cpp index e9fe307718..2016e278da 100644 --- a/test/api/api_misuse.test.cpp +++ b/test/api/api_misuse.test.cpp @@ -5,6 +5,7 @@ #include #include #include +#include #include #include @@ -22,8 +23,9 @@ TEST(API, RenderWithoutCallback) { HeadlessView view(display, 1); view.resize(128, 512); StubFileSource fileSource; + ThreadPool threadPool(4); - std::unique_ptr map = std::make_unique(view, fileSource, MapMode::Still); + std::unique_ptr map = std::make_unique(view, fileSource, threadPool, MapMode::Still); map->renderStill(nullptr); // Force Map thread to join. @@ -46,8 +48,9 @@ TEST(API, RenderWithoutStyle) { HeadlessView view(display, 1); view.resize(128, 512); StubFileSource fileSource; + ThreadPool threadPool(4); - Map map(view, fileSource, MapMode::Still); + Map map(view, fileSource, threadPool, MapMode::Still); std::exception_ptr error; map.renderStill([&](std::exception_ptr error_, PremultipliedImage&&) { diff --git a/test/api/custom_layer.test.cpp b/test/api/custom_layer.test.cpp index 2dded19256..1342dfa50c 100644 --- a/test/api/custom_layer.test.cpp +++ b/test/api/custom_layer.test.cpp @@ -4,6 +4,7 @@ #include #include #include +#include #include #include #include @@ -94,7 +95,9 @@ TEST(CustomLayer, Basic) { DefaultFileSource fileSource(":memory:", "test/fixtures/api/assets"); #endif - Map map(view, fileSource, MapMode::Still); + ThreadPool threadPool(4); + + Map map(view, fileSource, threadPool, MapMode::Still); map.setStyleJSON(util::read_file("test/fixtures/api/water.json")); map.setLatLngZoom({ 37.8, -122.5 }, 10); map.addLayer(std::make_unique( diff --git a/test/api/query.test.cpp b/test/api/query.test.cpp index 7da0f4311c..da38dd0cb2 100644 --- a/test/api/query.test.cpp +++ b/test/api/query.test.cpp @@ -1,6 +1,7 @@ #include #include #include +#include #include #include #include @@ -28,7 +29,8 @@ public: std::shared_ptr display { std::make_shared() }; HeadlessView view { display, 1 }; StubFileSource fileSource; - Map map { view, fileSource, MapMode::Still }; + ThreadPool threadPool { 4 }; + Map map { view, fileSource, threadPool, MapMode::Still }; }; } // end namespace diff --git a/test/api/render_missing.test.cpp b/test/api/render_missing.test.cpp index 024ebd3729..d57a5a98bd 100644 --- a/test/api/render_missing.test.cpp +++ b/test/api/render_missing.test.cpp @@ -2,8 +2,9 @@ #include #include -#include #include +#include +#include #include #include #include @@ -33,9 +34,11 @@ TEST(API, TEST_REQUIRES_SERVER(RenderMissingTile)) { DefaultFileSource fileSource(":memory:", "test/fixtures/api/assets"); #endif + ThreadPool threadPool(4); + Log::setObserver(std::make_unique()); - Map map(view, fileSource, MapMode::Still); + Map map(view, fileSource, threadPool, MapMode::Still); std::string message; diff --git a/test/api/repeated_render.test.cpp b/test/api/repeated_render.test.cpp index cf71cb8416..4229f9d7ad 100644 --- a/test/api/repeated_render.test.cpp +++ b/test/api/repeated_render.test.cpp @@ -2,8 +2,9 @@ #include #include -#include #include +#include +#include #include #include #include @@ -20,6 +21,7 @@ TEST(API, RepeatedRender) { auto display = std::make_shared(); HeadlessView view(display, 1, 256, 512); + #ifdef MBGL_ASSET_ZIP // Regenerate with `cd test/fixtures/api/ && zip -r assets.zip assets/` DefaultFileSource fileSource(":memory:", "test/fixtures/api/assets.zip"); @@ -27,9 +29,11 @@ TEST(API, RepeatedRender) { DefaultFileSource fileSource(":memory:", "test/fixtures/api/assets"); #endif + ThreadPool threadPool(4); + Log::setObserver(std::make_unique()); - Map map(view, fileSource, MapMode::Still); + Map map(view, fileSource, threadPool, MapMode::Still); { map.setStyleJSON(style); -- cgit v1.2.1