summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThiago Marcos P. Santos <tmpsantos@gmail.com>2019-02-14 16:56:17 +0200
committerBruno de Oliveira Abinader <bruno@mapbox.com>2019-03-08 18:36:02 +0200
commit9af70cb127d190a9b8257942c6080c8a1b440004 (patch)
tree708b1b01b3577d05b06273e5fc5b93b501be9788
parent5e2b6bf636472a4464e6ab3ae0d9d01c68de041b (diff)
downloadqtlocation-mapboxgl-9af70cb127d190a9b8257942c6080c8a1b440004.tar.gz
[core] Make the BackgroundScheduler a singleton
- Do not carry it over everywhere as parameter, it is a shared instance anyway and the lifecycle is pretty much the app lifecycle from the moment we instantiate a map. - Rename to BackgroundScheduler because it is a Scheduler that will do tasks in the background, we don't make assumptions if it is a thread pool or a single thread. - Most importantly, remove the dependency from `core` on `platform`.
-rw-r--r--benchmark/api/query.benchmark.cpp6
-rw-r--r--benchmark/api/render.benchmark.cpp14
-rw-r--r--bin/render.cpp6
-rw-r--r--include/mbgl/actor/scheduler.hpp3
-rw-r--r--include/mbgl/map/map.hpp2
-rw-r--r--include/mbgl/renderer/renderer.hpp3
-rw-r--r--include/mbgl/style/style.hpp3
-rw-r--r--platform/android/core-files.json7
-rw-r--r--platform/android/src/map_renderer.cpp4
-rwxr-xr-xplatform/android/src/native_map_view.cpp6
-rwxr-xr-xplatform/android/src/native_map_view.hpp2
-rw-r--r--platform/android/src/snapshotter/map_snapshotter.cpp5
-rw-r--r--platform/android/src/snapshotter/map_snapshotter.hpp2
-rw-r--r--platform/android/src/style/sources/geojson_source.cpp7
-rw-r--r--platform/darwin/src/MGLMapSnapshotter.mm7
-rw-r--r--platform/default/include/mbgl/gl/headless_frontend.hpp5
-rw-r--r--platform/default/include/mbgl/map/map_snapshotter.hpp1
-rw-r--r--platform/default/include/mbgl/util/default_thread_pool.hpp27
-rw-r--r--platform/default/include/mbgl/util/shared_thread_pool.hpp9
-rw-r--r--platform/default/src/mbgl/gl/headless_frontend.cpp8
-rw-r--r--platform/default/src/mbgl/map/map_snapshotter.cpp11
-rw-r--r--platform/default/src/mbgl/platform/thread_pool.cpp (renamed from platform/default/src/mbgl/util/default_thread_pool.cpp)28
-rw-r--r--platform/default/src/mbgl/util/shared_thread_pool.cpp14
-rw-r--r--platform/glfw/main.cpp6
-rw-r--r--platform/ios/core-files.json7
-rw-r--r--platform/ios/src/MGLMapView.mm10
-rw-r--r--platform/linux/config.cmake4
-rw-r--r--platform/macos/core-files.json7
-rw-r--r--platform/macos/src/MGLMapView.mm8
-rw-r--r--platform/node/src/node_map.cpp7
-rw-r--r--platform/node/src/node_map.hpp3
-rw-r--r--platform/node/src/node_thread_pool.cpp12
-rw-r--r--platform/qt/qt.cmake5
-rw-r--r--platform/qt/src/qmapboxgl.cpp5
-rw-r--r--platform/qt/src/qmapboxgl_map_renderer.cpp4
-rw-r--r--platform/qt/src/qmapboxgl_map_renderer.hpp3
-rw-r--r--platform/qt/src/qmapboxgl_p.hpp2
-rw-r--r--platform/qt/src/qmapboxgl_renderer_backend.hpp1
-rw-r--r--src/mbgl/map/map.cpp3
-rw-r--r--src/mbgl/map/map_impl.cpp4
-rw-r--r--src/mbgl/map/map_impl.hpp3
-rw-r--r--src/mbgl/renderer/renderer.cpp3
-rw-r--r--src/mbgl/renderer/renderer_impl.cpp3
-rw-r--r--src/mbgl/renderer/renderer_impl.hpp4
-rw-r--r--src/mbgl/renderer/tile_parameters.hpp2
-rw-r--r--src/mbgl/sprite/sprite_loader.cpp8
-rw-r--r--src/mbgl/sprite/sprite_loader.hpp3
-rw-r--r--src/mbgl/style/sources/custom_geometry_source.cpp3
-rw-r--r--src/mbgl/style/style.cpp4
-rw-r--r--src/mbgl/style/style_impl.cpp7
-rw-r--r--src/mbgl/style/style_impl.hpp4
-rw-r--r--src/mbgl/tile/geometry_tile.cpp3
-rw-r--r--src/mbgl/tile/raster_dem_tile.cpp3
-rw-r--r--src/mbgl/tile/raster_tile.cpp3
-rw-r--r--test/actor/actor.test.cpp41
-rw-r--r--test/actor/actor_ref.test.cpp14
-rw-r--r--test/api/annotations.test.cpp6
-rw-r--r--test/api/api_misuse.test.cpp6
-rw-r--r--test/api/custom_geometry_source.test.cpp6
-rw-r--r--test/api/custom_layer.test.cpp6
-rw-r--r--test/api/query.test.cpp6
-rw-r--r--test/api/recycle_map.cpp6
-rw-r--r--test/gl/context.test.cpp6
-rw-r--r--test/map/map.test.cpp15
-rw-r--r--test/map/prefetch.test.cpp6
-rw-r--r--test/renderer/image_manager.test.cpp1
-rw-r--r--test/sprite/sprite_loader.test.cpp4
-rw-r--r--test/style/source.test.cpp6
-rw-r--r--test/style/style.test.cpp10
-rw-r--r--test/style/style_layer.test.cpp4
-rw-r--r--test/text/local_glyph_rasterizer.test.cpp6
-rw-r--r--test/tile/custom_geometry_tile.test.cpp5
-rw-r--r--test/tile/geojson_tile.test.cpp5
-rw-r--r--test/tile/raster_dem_tile.test.cpp5
-rw-r--r--test/tile/raster_tile.test.cpp5
-rw-r--r--test/tile/vector_tile.test.cpp5
-rw-r--r--test/util/async_task.test.cpp16
-rw-r--r--test/util/memory.test.cpp16
-rw-r--r--test/util/thread.test.cpp10
79 files changed, 182 insertions, 358 deletions
diff --git a/benchmark/api/query.benchmark.cpp b/benchmark/api/query.benchmark.cpp
index 275a79372c..ab2adbacee 100644
--- a/benchmark/api/query.benchmark.cpp
+++ b/benchmark/api/query.benchmark.cpp
@@ -3,7 +3,6 @@
#include <mbgl/map/map.hpp>
#include <mbgl/map/map_options.hpp>
#include <mbgl/gl/headless_frontend.hpp>
-#include <mbgl/util/default_thread_pool.hpp>
#include <mbgl/renderer/renderer.hpp>
#include <mbgl/style/style.hpp>
#include <mbgl/style/image.hpp>
@@ -33,10 +32,9 @@ public:
util::RunLoop loop;
DefaultFileSource fileSource{ "benchmark/fixtures/api/cache.db", "." };
- ThreadPool threadPool{ 4 };
- HeadlessFrontend frontend { { 1000, 1000 }, 1, fileSource, threadPool };
+ HeadlessFrontend frontend { { 1000, 1000 }, 1, fileSource };
Map map { frontend, MapObserver::nullObserver(), frontend.getSize(), 1,
- fileSource, threadPool, MapOptions().withMapMode(MapMode::Static) };
+ fileSource, MapOptions().withMapMode(MapMode::Static) };
ScreenBox box{{ 0, 0 }, { 1000, 1000 }};
};
diff --git a/benchmark/api/render.benchmark.cpp b/benchmark/api/render.benchmark.cpp
index 8709f18d9c..d2827ed902 100644
--- a/benchmark/api/render.benchmark.cpp
+++ b/benchmark/api/render.benchmark.cpp
@@ -4,7 +4,6 @@
#include <mbgl/map/map_observer.hpp>
#include <mbgl/map/map_options.hpp>
#include <mbgl/gl/headless_frontend.hpp>
-#include <mbgl/util/default_thread_pool.hpp>
#include <mbgl/renderer/renderer.hpp>
#include <mbgl/style/style.hpp>
#include <mbgl/style/image.hpp>
@@ -27,7 +26,6 @@ public:
util::RunLoop loop;
DefaultFileSource fileSource { "benchmark/fixtures/api/cache.db", "." };
- ThreadPool threadPool { 4 };
};
static void prepare(Map& map, optional<std::string> json = {}) {
@@ -41,9 +39,9 @@ static void prepare(Map& map, optional<std::string> json = {}) {
static void API_renderStill_reuse_map(::benchmark::State& state) {
RenderBenchmark bench;
- HeadlessFrontend frontend { { 1000, 1000 }, 1, bench.fileSource, bench.threadPool };
+ HeadlessFrontend frontend { { 1000, 1000 }, 1, bench.fileSource };
Map map { frontend, MapObserver::nullObserver(), frontend.getSize(), 1,
- bench.fileSource, bench.threadPool, MapOptions().withMapMode(MapMode::Static) };
+ bench.fileSource, MapOptions().withMapMode(MapMode::Static) };
prepare(map);
while (state.KeepRunning()) {
@@ -53,9 +51,9 @@ static void API_renderStill_reuse_map(::benchmark::State& state) {
static void API_renderStill_reuse_map_switch_styles(::benchmark::State& state) {
RenderBenchmark bench;
- HeadlessFrontend frontend { { 1000, 1000 }, 1, bench.fileSource, bench.threadPool };
+ HeadlessFrontend frontend { { 1000, 1000 }, 1, bench.fileSource };
Map map { frontend, MapObserver::nullObserver(), frontend.getSize(), 1,
- bench.fileSource, bench.threadPool, MapOptions().withMapMode(MapMode::Static) };
+ bench.fileSource, MapOptions().withMapMode(MapMode::Static) };
while (state.KeepRunning()) {
prepare(map, { "{}" });
@@ -69,9 +67,9 @@ static void API_renderStill_recreate_map(::benchmark::State& state) {
RenderBenchmark bench;
while (state.KeepRunning()) {
- HeadlessFrontend frontend { { 1000, 1000 }, 1, bench.fileSource, bench.threadPool };
+ HeadlessFrontend frontend { { 1000, 1000 }, 1, bench.fileSource };
Map map { frontend, MapObserver::nullObserver(), frontend.getSize(), 1,
- bench.fileSource, bench.threadPool, MapOptions().withMapMode(MapMode::Static) };
+ bench.fileSource, MapOptions().withMapMode(MapMode::Static) };
prepare(map);
frontend.render(map);
}
diff --git a/bin/render.cpp b/bin/render.cpp
index fbf32f9a40..42b6dac10b 100644
--- a/bin/render.cpp
+++ b/bin/render.cpp
@@ -5,7 +5,6 @@
#include <mbgl/util/default_styles.hpp>
#include <mbgl/gl/headless_frontend.hpp>
-#include <mbgl/util/default_thread_pool.hpp>
#include <mbgl/storage/default_file_source.hpp>
#include <mbgl/style/style.hpp>
@@ -83,10 +82,9 @@ int main(int argc, char *argv[]) {
fileSource.setAccessToken(std::string(token));
}
- ThreadPool threadPool(4);
- HeadlessFrontend frontend({ width, height }, pixelRatio, fileSource, threadPool);
+ HeadlessFrontend frontend({ width, height }, pixelRatio, fileSource);
Map map(frontend, MapObserver::nullObserver(), frontend.getSize(), pixelRatio,
- fileSource, threadPool, MapOptions().withMapMode(MapMode::Static));
+ fileSource, MapOptions().withMapMode(MapMode::Static));
if (style.find("://") == std::string::npos) {
style = std::string("file://") + style;
diff --git a/include/mbgl/actor/scheduler.hpp b/include/mbgl/actor/scheduler.hpp
index 75ead29f0a..f80bad8fc3 100644
--- a/include/mbgl/actor/scheduler.hpp
+++ b/include/mbgl/actor/scheduler.hpp
@@ -41,6 +41,9 @@ public:
// Set/Get the current Scheduler for this thread
static Scheduler* GetCurrent();
static void SetCurrent(Scheduler*);
+
+ // Set/Get the current Scheduler for this thread
+ static Scheduler& GetBackground();
};
} // namespace mbgl
diff --git a/include/mbgl/map/map.hpp b/include/mbgl/map/map.hpp
index 548a9f6257..096bb90131 100644
--- a/include/mbgl/map/map.hpp
+++ b/include/mbgl/map/map.hpp
@@ -21,7 +21,6 @@
namespace mbgl {
class FileSource;
-class Scheduler;
class RendererFrontend;
namespace style {
@@ -36,7 +35,6 @@ public:
Size size,
float pixelRatio,
FileSource&,
- Scheduler&,
const MapOptions&);
~Map();
diff --git a/include/mbgl/renderer/renderer.hpp b/include/mbgl/renderer/renderer.hpp
index 644dd0fcf9..d75d8363a6 100644
--- a/include/mbgl/renderer/renderer.hpp
+++ b/include/mbgl/renderer/renderer.hpp
@@ -17,13 +17,12 @@ class FileSource;
class RendererBackend;
class RendererObserver;
class RenderedQueryOptions;
-class Scheduler;
class SourceQueryOptions;
class UpdateParameters;
class Renderer {
public:
- Renderer(RendererBackend&, float pixelRatio_, FileSource&, Scheduler&,
+ Renderer(RendererBackend&, float pixelRatio_, FileSource&,
GLContextMode = GLContextMode::Unique,
const optional<std::string> programCacheDir = {},
const optional<std::string> localFontFamily = {});
diff --git a/include/mbgl/style/style.hpp b/include/mbgl/style/style.hpp
index d6fdbd8f2c..4a6a542b88 100644
--- a/include/mbgl/style/style.hpp
+++ b/include/mbgl/style/style.hpp
@@ -11,7 +11,6 @@
namespace mbgl {
class FileSource;
-class Scheduler;
namespace style {
@@ -22,7 +21,7 @@ class Layer;
class Style {
public:
- Style(Scheduler&, FileSource&, float pixelRatio);
+ Style(FileSource&, float pixelRatio);
~Style();
void loadJSON(const std::string&);
diff --git a/platform/android/core-files.json b/platform/android/core-files.json
index 20dcc12c7d..78764e99bc 100644
--- a/platform/android/core-files.json
+++ b/platform/android/core-files.json
@@ -88,10 +88,9 @@
"platform/default/src/mbgl/gl/headless_backend.cpp",
"platform/default/src/mbgl/gl/headless_frontend.cpp",
"platform/default/src/mbgl/map/map_snapshotter.cpp",
+ "platform/default/src/mbgl/platform/thread_pool.cpp",
"platform/default/src/mbgl/text/bidi.cpp",
- "platform/default/src/mbgl/util/default_thread_pool.cpp",
"platform/default/src/mbgl/util/png_writer.cpp",
- "platform/default/src/mbgl/util/shared_thread_pool.cpp",
"platform/default/src/mbgl/util/thread_local.cpp",
"platform/default/src/mbgl/util/utf.cpp",
"platform/linux/src/headless_backend_egl.cpp"
@@ -101,9 +100,7 @@
"mbgl/gl/headless_backend.hpp": "platform/default/include/mbgl/gl/headless_backend.hpp",
"mbgl/gl/headless_frontend.hpp": "platform/default/include/mbgl/gl/headless_frontend.hpp",
"mbgl/map/map_snapshotter.hpp": "platform/default/include/mbgl/map/map_snapshotter.hpp",
- "mbgl/text/unaccent.hpp": "platform/default/include/mbgl/text/unaccent.hpp",
- "mbgl/util/default_thread_pool.hpp": "platform/default/include/mbgl/util/default_thread_pool.hpp",
- "mbgl/util/shared_thread_pool.hpp": "platform/default/include/mbgl/util/shared_thread_pool.hpp"
+ "mbgl/text/unaccent.hpp": "platform/default/include/mbgl/text/unaccent.hpp"
},
"private_headers": {
"android_renderer_backend.hpp": "platform/android/src/android_renderer_backend.hpp",
diff --git a/platform/android/src/map_renderer.cpp b/platform/android/src/map_renderer.cpp
index cd8953e4cf..1974579b44 100644
--- a/platform/android/src/map_renderer.cpp
+++ b/platform/android/src/map_renderer.cpp
@@ -1,7 +1,6 @@
#include "map_renderer.hpp"
#include <mbgl/renderer/renderer.hpp>
-#include <mbgl/util/shared_thread_pool.hpp>
#include <mbgl/util/run_loop.hpp>
#include <string>
@@ -25,7 +24,6 @@ MapRenderer::MapRenderer(jni::JNIEnv& _env,
, fileSource(FileSource::getDefaultFileSource(_env, _fileSource))
, programCacheDir(jni::Make<std::string>(_env, programCacheDir_))
, localIdeographFontFamily(localIdeographFontFamily_ ? jni::Make<std::string>(_env, localIdeographFontFamily_) : optional<std::string>{})
- , threadPool(sharedThreadPool())
, mailbox(std::make_shared<Mailbox>(*this)) {
}
@@ -174,7 +172,7 @@ void MapRenderer::onSurfaceCreated(JNIEnv&) {
// Create the new backend and renderer
backend = std::make_unique<AndroidRendererBackend>();
- renderer = std::make_unique<Renderer>(*backend, pixelRatio, fileSource, *threadPool,
+ renderer = std::make_unique<Renderer>(*backend, pixelRatio, fileSource,
GLContextMode::Unique, programCacheDir, localIdeographFontFamily);
rendererRef = std::make_unique<ActorRef<Renderer>>(*renderer, mailbox);
diff --git a/platform/android/src/native_map_view.cpp b/platform/android/src/native_map_view.cpp
index 2f23f0b7d9..98aaedb7ab 100755
--- a/platform/android/src/native_map_view.cpp
+++ b/platform/android/src/native_map_view.cpp
@@ -20,7 +20,6 @@
#include <mbgl/util/exception.hpp>
#include <mbgl/util/geo.hpp>
#include <mbgl/util/image.hpp>
-#include <mbgl/util/shared_thread_pool.hpp>
#include <mbgl/util/logging.hpp>
#include <mbgl/util/platform.hpp>
#include <mbgl/util/projection.hpp>
@@ -65,8 +64,7 @@ NativeMapView::NativeMapView(jni::JNIEnv& _env,
jni::jboolean _crossSourceCollisions)
: javaPeer(_env, _obj)
, mapRenderer(MapRenderer::getNativePeer(_env, jMapRenderer))
- , pixelRatio(_pixelRatio)
- , threadPool(sharedThreadPool()) {
+ , pixelRatio(_pixelRatio) {
// Get a reference to the JavaVM for callbacks
if (_env.GetJavaVM(&vm) < 0) {
@@ -91,7 +89,7 @@ NativeMapView::NativeMapView(jni::JNIEnv& _env,
map = std::make_unique<mbgl::Map>(*rendererFrontend, *this,
mbgl::Size{ static_cast<uint32_t>(width),
static_cast<uint32_t>(height) }, pixelRatio,
- fileSource, *threadPool, options);
+ fileSource, options);
}
/**
diff --git a/platform/android/src/native_map_view.hpp b/platform/android/src/native_map_view.hpp
index 1bb4f23cbe..e0d239073b 100755
--- a/platform/android/src/native_map_view.hpp
+++ b/platform/android/src/native_map_view.hpp
@@ -4,7 +4,6 @@
#include <mbgl/map/camera.hpp>
#include <mbgl/map/map.hpp>
#include <mbgl/util/noncopyable.hpp>
-#include <mbgl/util/default_thread_pool.hpp>
#include <mbgl/util/run_loop.hpp>
#include <mbgl/storage/default_file_source.hpp>
#include <mbgl/storage/network_status.hpp>
@@ -258,7 +257,6 @@ private:
int height = 64;
// Ensure these are initialised last
- std::shared_ptr<mbgl::ThreadPool> threadPool;
std::unique_ptr<mbgl::Map> map;
mbgl::EdgeInsets insets;
};
diff --git a/platform/android/src/snapshotter/map_snapshotter.cpp b/platform/android/src/snapshotter/map_snapshotter.cpp
index 8eb1d02605..dd0ce6ea05 100644
--- a/platform/android/src/snapshotter/map_snapshotter.cpp
+++ b/platform/android/src/snapshotter/map_snapshotter.cpp
@@ -2,7 +2,6 @@
#include <mbgl/renderer/renderer.hpp>
#include <mbgl/style/style.hpp>
-#include <mbgl/util/shared_thread_pool.hpp>
#include <mbgl/util/logging.hpp>
#include <mbgl/util/string.hpp>
#include <mbgl/actor/scheduler.hpp>
@@ -27,8 +26,7 @@ MapSnapshotter::MapSnapshotter(jni::JNIEnv& _env,
const jni::String& _programCacheDir,
const jni::String& _localIdeographFontFamily)
: javaPeer(_env, _obj)
- , pixelRatio(_pixelRatio)
- , threadPool(sharedThreadPool()) {
+ , pixelRatio(_pixelRatio) {
// Get a reference to the JavaVM for callbacks
if (_env.GetJavaVM(&vm) < 0) {
@@ -60,7 +58,6 @@ MapSnapshotter::MapSnapshotter(jni::JNIEnv& _env,
showLogo = _showLogo;
// Create the core snapshotter
snapshotter = std::make_unique<mbgl::MapSnapshotter>(&fileSource,
- threadPool,
style,
size,
pixelRatio,
diff --git a/platform/android/src/snapshotter/map_snapshotter.hpp b/platform/android/src/snapshotter/map_snapshotter.hpp
index e8c0885ff1..791aa61d6a 100644
--- a/platform/android/src/snapshotter/map_snapshotter.hpp
+++ b/platform/android/src/snapshotter/map_snapshotter.hpp
@@ -1,7 +1,6 @@
#pragma once
#include <mbgl/map/map_snapshotter.hpp>
-#include <mbgl/util/default_thread_pool.hpp>
#include <mbgl/util/util.hpp>
#include "../file_source.hpp"
@@ -63,7 +62,6 @@ private:
float pixelRatio;
bool showLogo;
- std::shared_ptr<mbgl::ThreadPool> threadPool;
std::unique_ptr<Actor<mbgl::MapSnapshotter::Callback>> snapshotCallback;
std::unique_ptr<mbgl::MapSnapshotter> snapshotter;
diff --git a/platform/android/src/style/sources/geojson_source.cpp b/platform/android/src/style/sources/geojson_source.cpp
index a9307afe67..5ff4864275 100644
--- a/platform/android/src/style/sources/geojson_source.cpp
+++ b/platform/android/src/style/sources/geojson_source.cpp
@@ -17,7 +17,6 @@
#include "../conversion/url_or_tileset.hpp"
#include <string>
-#include <mbgl/util/shared_thread_pool.hpp>
// GeoJSONSource uses a "coalescing" model for high frequency asynchronous data update calls,
// which in practice means, that any update that started processing is going to finish
@@ -48,16 +47,14 @@ namespace android {
: Source(env, std::make_unique<mbgl::style::GeoJSONSource>(
jni::Make<std::string>(env, sourceId),
convertGeoJSONOptions(env, options)))
- , threadPool(sharedThreadPool())
- , converter(std::make_unique<Actor<FeatureConverter>>(*threadPool)) {
+ , converter(std::make_unique<Actor<FeatureConverter>>(Scheduler::GetBackground())) {
}
GeoJSONSource::GeoJSONSource(jni::JNIEnv& env,
mbgl::style::Source& coreSource,
AndroidRendererFrontend& frontend)
: Source(env, coreSource, createJavaPeer(env), frontend)
- , threadPool(sharedThreadPool())
- , converter(std::make_unique<Actor<FeatureConverter>>(*threadPool)) {
+ , converter(std::make_unique<Actor<FeatureConverter>>(Scheduler::GetBackground())) {
}
GeoJSONSource::~GeoJSONSource() = default;
diff --git a/platform/darwin/src/MGLMapSnapshotter.mm b/platform/darwin/src/MGLMapSnapshotter.mm
index 3918008b78..7fc21c56c0 100644
--- a/platform/darwin/src/MGLMapSnapshotter.mm
+++ b/platform/darwin/src/MGLMapSnapshotter.mm
@@ -6,9 +6,7 @@
#import <mbgl/map/map_snapshotter.hpp>
#import <mbgl/map/camera.hpp>
#import <mbgl/storage/default_file_source.hpp>
-#import <mbgl/util/default_thread_pool.hpp>
#import <mbgl/util/string.hpp>
-#import <mbgl/util/shared_thread_pool.hpp>
#import "MGLOfflineStorage_Private.h"
#import "MGLGeometry_Private.h"
@@ -123,7 +121,6 @@ const CGFloat MGLSnapshotterMinimumPixelSize = 64;
@end
@implementation MGLMapSnapshotter {
- std::shared_ptr<mbgl::ThreadPool> _mbglThreadPool;
std::unique_ptr<mbgl::MapSnapshotter> _mbglMapSnapshotter;
std::unique_ptr<mbgl::Actor<mbgl::MapSnapshotter::Callback>> _snapshotCallback;
}
@@ -174,7 +171,6 @@ const CGFloat MGLSnapshotterMinimumPixelSize = 64;
_mbglMapSnapshotter.reset();
_snapshotCallback.reset();
- _mbglThreadPool.reset();
self.terminated = YES;
}
@@ -588,7 +584,6 @@ const CGFloat MGLSnapshotterMinimumPixelSize = 64;
_cancelled = NO;
_options = options;
mbgl::DefaultFileSource *mbglFileSource = [MGLOfflineStorage sharedOfflineStorage].mbglFileSource;
- _mbglThreadPool = mbgl::sharedThreadPool();
std::string styleURL = std::string([options.styleURL.absoluteString UTF8String]);
std::pair<bool, std::string> style = std::make_pair(false, styleURL);
@@ -621,7 +616,7 @@ const CGFloat MGLSnapshotterMinimumPixelSize = 64;
MGLRendererConfiguration* config = [MGLRendererConfiguration currentConfiguration];
// Create the snapshotter
- _mbglMapSnapshotter = std::make_unique<mbgl::MapSnapshotter>(mbglFileSource, _mbglThreadPool, style, size, pixelRatio, cameraOptions, coordinateBounds, config.cacheDir, config.localFontFamilyName);
+ _mbglMapSnapshotter = std::make_unique<mbgl::MapSnapshotter>(mbglFileSource, style, size, pixelRatio, cameraOptions, coordinateBounds, config.cacheDir, config.localFontFamilyName);
}
@end
diff --git a/platform/default/include/mbgl/gl/headless_frontend.hpp b/platform/default/include/mbgl/gl/headless_frontend.hpp
index 18f0cfa537..d32c2e7768 100644
--- a/platform/default/include/mbgl/gl/headless_frontend.hpp
+++ b/platform/default/include/mbgl/gl/headless_frontend.hpp
@@ -12,7 +12,6 @@
namespace mbgl {
class FileSource;
-class Scheduler;
class Renderer;
class RendererBackend;
class Map;
@@ -20,8 +19,8 @@ class TransformState;
class HeadlessFrontend : public RendererFrontend {
public:
- HeadlessFrontend(float pixelRatio_, FileSource&, Scheduler&, const optional<std::string> programCacheDir = {}, GLContextMode mode = GLContextMode::Unique, const optional<std::string> localFontFamily = {});
- HeadlessFrontend(Size, float pixelRatio_, FileSource&, Scheduler&, const optional<std::string> programCacheDir = {}, GLContextMode mode = GLContextMode::Unique, const optional<std::string> localFontFamily = {});
+ HeadlessFrontend(float pixelRatio_, FileSource&, const optional<std::string> programCacheDir = {}, GLContextMode mode = GLContextMode::Unique, const optional<std::string> localFontFamily = {});
+ HeadlessFrontend(Size, float pixelRatio_, FileSource&, const optional<std::string> programCacheDir = {}, GLContextMode mode = GLContextMode::Unique, const optional<std::string> localFontFamily = {});
~HeadlessFrontend() override;
void reset() override;
diff --git a/platform/default/include/mbgl/map/map_snapshotter.hpp b/platform/default/include/mbgl/map/map_snapshotter.hpp
index 2deb2b3cda..8c4b3e023e 100644
--- a/platform/default/include/mbgl/map/map_snapshotter.hpp
+++ b/platform/default/include/mbgl/map/map_snapshotter.hpp
@@ -26,7 +26,6 @@ class Style;
class MapSnapshotter {
public:
MapSnapshotter(FileSource* fileSource,
- std::shared_ptr<Scheduler> scheduler,
const std::pair<bool, std::string> style,
const Size&,
const float pixelRatio,
diff --git a/platform/default/include/mbgl/util/default_thread_pool.hpp b/platform/default/include/mbgl/util/default_thread_pool.hpp
deleted file mode 100644
index a14d16d771..0000000000
--- a/platform/default/include/mbgl/util/default_thread_pool.hpp
+++ /dev/null
@@ -1,27 +0,0 @@
-#pragma once
-
-#include <mbgl/actor/scheduler.hpp>
-
-#include <condition_variable>
-#include <mutex>
-#include <queue>
-#include <thread>
-
-namespace mbgl {
-
-class ThreadPool : public Scheduler {
-public:
- ThreadPool(std::size_t count);
- ~ThreadPool() override;
-
- void schedule(std::weak_ptr<Mailbox>) override;
-
-private:
- std::vector<std::thread> threads;
- std::queue<std::weak_ptr<Mailbox>> queue;
- std::mutex mutex;
- std::condition_variable cv;
- bool terminate { false };
-};
-
-} // namespace mbgl
diff --git a/platform/default/include/mbgl/util/shared_thread_pool.hpp b/platform/default/include/mbgl/util/shared_thread_pool.hpp
deleted file mode 100644
index 04a3cb58d5..0000000000
--- a/platform/default/include/mbgl/util/shared_thread_pool.hpp
+++ /dev/null
@@ -1,9 +0,0 @@
-#pragma once
-
-#include <mbgl/util/default_thread_pool.hpp>
-
-namespace mbgl {
-
-std::shared_ptr<ThreadPool> sharedThreadPool();
-
-} // namespace mbgl
diff --git a/platform/default/src/mbgl/gl/headless_frontend.cpp b/platform/default/src/mbgl/gl/headless_frontend.cpp
index 37b0f91f32..71cd656e59 100644
--- a/platform/default/src/mbgl/gl/headless_frontend.cpp
+++ b/platform/default/src/mbgl/gl/headless_frontend.cpp
@@ -8,11 +8,11 @@
namespace mbgl {
-HeadlessFrontend::HeadlessFrontend(float pixelRatio_, FileSource& fileSource, Scheduler& scheduler, const optional<std::string> programCacheDir, GLContextMode mode, const optional<std::string> localFontFamily)
- : HeadlessFrontend({ 256, 256 }, pixelRatio_, fileSource, scheduler, programCacheDir, mode, localFontFamily) {
+HeadlessFrontend::HeadlessFrontend(float pixelRatio_, FileSource& fileSource, const optional<std::string> programCacheDir, GLContextMode mode, const optional<std::string> localFontFamily)
+ : HeadlessFrontend({ 256, 256 }, pixelRatio_, fileSource, programCacheDir, mode, localFontFamily) {
}
-HeadlessFrontend::HeadlessFrontend(Size size_, float pixelRatio_, FileSource& fileSource, Scheduler& scheduler, const optional<std::string> programCacheDir, GLContextMode mode, const optional<std::string> localFontFamily)
+HeadlessFrontend::HeadlessFrontend(Size size_, float pixelRatio_, FileSource& fileSource, const optional<std::string> programCacheDir, GLContextMode mode, const optional<std::string> localFontFamily)
: size(size_),
pixelRatio(pixelRatio_),
backend({ static_cast<uint32_t>(size.width * pixelRatio),
@@ -23,7 +23,7 @@ HeadlessFrontend::HeadlessFrontend(Size size_, float pixelRatio_, FileSource& fi
renderer->render(*updateParameters);
}
}),
- renderer(std::make_unique<Renderer>(backend, pixelRatio, fileSource, scheduler, mode, programCacheDir, localFontFamily)) {
+ renderer(std::make_unique<Renderer>(backend, pixelRatio, fileSource, mode, programCacheDir, localFontFamily)) {
}
HeadlessFrontend::~HeadlessFrontend() = default;
diff --git a/platform/default/src/mbgl/map/map_snapshotter.cpp b/platform/default/src/mbgl/map/map_snapshotter.cpp
index 56bc9bdb88..9532b01b7e 100644
--- a/platform/default/src/mbgl/map/map_snapshotter.cpp
+++ b/platform/default/src/mbgl/map/map_snapshotter.cpp
@@ -15,7 +15,6 @@ namespace mbgl {
class MapSnapshotter::Impl {
public:
Impl(FileSource*,
- std::shared_ptr<Scheduler>,
const std::pair<bool, std::string> style,
const Size&,
const float pixelRatio,
@@ -42,13 +41,11 @@ public:
void snapshot(ActorRef<MapSnapshotter::Callback>);
private:
- std::shared_ptr<Scheduler> scheduler;
HeadlessFrontend frontend;
Map map;
};
MapSnapshotter::Impl::Impl(FileSource* fileSource,
- std::shared_ptr<Scheduler> scheduler_,
const std::pair<bool, std::string> style,
const Size& size,
const float pixelRatio,
@@ -56,9 +53,8 @@ MapSnapshotter::Impl::Impl(FileSource* fileSource,
const optional<LatLngBounds> region,
const optional<std::string> programCacheDir,
const optional<std::string> localFontFamily)
- : scheduler(std::move(scheduler_))
- , frontend(size, pixelRatio, *fileSource, *scheduler, programCacheDir, GLContextMode::Unique, localFontFamily)
- , map(frontend, MapObserver::nullObserver(), size, pixelRatio, *fileSource, *scheduler, MapOptions().withMapMode(MapMode::Static)) {
+ , frontend(size, pixelRatio, programCacheDir, GLContextMode::Unique, localFontFamily)
+ , map(frontend, MapObserver::nullObserver(), size, pixelRatio, *fileSource, MapOptions().withMapMode(MapMode::Static)) {
if (style.first) {
map.getStyle().loadJSON(style.second);
@@ -165,7 +161,6 @@ LatLngBounds MapSnapshotter::Impl::getRegion() const {
}
MapSnapshotter::MapSnapshotter(FileSource* fileSource,
- std::shared_ptr<Scheduler> scheduler,
const std::pair<bool, std::string> style,
const Size& size,
const float pixelRatio,
@@ -173,7 +168,7 @@ MapSnapshotter::MapSnapshotter(FileSource* fileSource,
const optional<LatLngBounds> region,
const optional<std::string> programCacheDir,
const optional<std::string> localFontFamily)
- : impl(std::make_unique<util::Thread<MapSnapshotter::Impl>>("Map Snapshotter", fileSource, std::move(scheduler), style, size, pixelRatio, cameraOptions, region, programCacheDir, localFontFamily)) {
+ : impl(std::make_unique<util::Thread<MapSnapshotter::Impl>>("Map Snapshotter", fileSource, style, size, pixelRatio, cameraOptions, region, programCacheDir, localFontFamily)) {
}
MapSnapshotter::~MapSnapshotter() = default;
diff --git a/platform/default/src/mbgl/util/default_thread_pool.cpp b/platform/default/src/mbgl/platform/thread_pool.cpp
index d3950bb8aa..d213aab71c 100644
--- a/platform/default/src/mbgl/util/default_thread_pool.cpp
+++ b/platform/default/src/mbgl/platform/thread_pool.cpp
@@ -1,12 +1,33 @@
-#include <mbgl/util/default_thread_pool.hpp>
+#include <mbgl/actor/scheduler.hpp>
#include <mbgl/actor/mailbox.hpp>
#include <mbgl/util/platform.hpp>
#include <mbgl/util/string.hpp>
+#include <condition_variable>
+#include <mutex>
+#include <queue>
+#include <thread>
+
namespace mbgl {
+class ThreadPool final : public Scheduler {
+public:
+ explicit ThreadPool(std::size_t count);
+ ~ThreadPool() override;
+
+ void schedule(std::weak_ptr<Mailbox>) override;
+
+private:
+ std::vector<std::thread> threads;
+ std::queue<std::weak_ptr<Mailbox>> queue;
+ std::mutex mutex;
+ std::condition_variable cv;
+ bool terminate { false };
+};
+
ThreadPool::ThreadPool(std::size_t count) {
threads.reserve(count);
+
for (std::size_t i = 0; i < count; ++i) {
threads.emplace_back([this, i]() {
platform::setCurrentThreadName(std::string{ "Worker " } + util::toString(i + 1));
@@ -54,4 +75,9 @@ void ThreadPool::schedule(std::weak_ptr<Mailbox> mailbox) {
cv.notify_one();
}
+Scheduler& Scheduler::GetBackground() {
+ static std::unique_ptr<ThreadPool> pool(new ThreadPool(4));
+ return *pool;
+}
+
} // namespace mbgl
diff --git a/platform/default/src/mbgl/util/shared_thread_pool.cpp b/platform/default/src/mbgl/util/shared_thread_pool.cpp
deleted file mode 100644
index d7facbab94..0000000000
--- a/platform/default/src/mbgl/util/shared_thread_pool.cpp
+++ /dev/null
@@ -1,14 +0,0 @@
-#include <mbgl/util/shared_thread_pool.hpp>
-
-namespace mbgl {
-
-std::shared_ptr<ThreadPool> sharedThreadPool() {
- static std::weak_ptr<ThreadPool> weak;
- auto pool = weak.lock();
- if (!pool) {
- weak = pool = std::make_shared<ThreadPool>(4);
- }
- return pool;
-}
-
-} // namespace mbgl
diff --git a/platform/glfw/main.cpp b/platform/glfw/main.cpp
index 8e6905f948..b66acf8088 100644
--- a/platform/glfw/main.cpp
+++ b/platform/glfw/main.cpp
@@ -5,7 +5,6 @@
#include <mbgl/util/default_styles.hpp>
#include <mbgl/util/logging.hpp>
#include <mbgl/util/platform.hpp>
-#include <mbgl/util/default_thread_pool.hpp>
#include <mbgl/storage/default_file_source.hpp>
#include <mbgl/style/style.hpp>
#include <mbgl/renderer/renderer.hpp>
@@ -107,9 +106,8 @@ int main(int argc, char *argv[]) {
fileSource.setAccessToken(std::string(token));
}
- mbgl::ThreadPool threadPool(4);
- GLFWRendererFrontend rendererFrontend { std::make_unique<mbgl::Renderer>(backend, view->getPixelRatio(), fileSource, threadPool), backend };
- mbgl::Map map(rendererFrontend, backend, view->getSize(), view->getPixelRatio(), fileSource, threadPool, mbgl::MapOptions());
+ GLFWRendererFrontend rendererFrontend { std::make_unique<mbgl::Renderer>(backend, view->getPixelRatio(), fileSource), backend };
+ mbgl::Map map(rendererFrontend, backend, view->getSize(), view->getPixelRatio(), fileSource, mbgl::MapOptions());
backend.setMap(&map);
diff --git a/platform/ios/core-files.json b/platform/ios/core-files.json
index c3e54a45b0..26a7857dd2 100644
--- a/platform/ios/core-files.json
+++ b/platform/ios/core-files.json
@@ -13,10 +13,9 @@
"platform/default/src/mbgl/gl/headless_backend.cpp",
"platform/default/src/mbgl/gl/headless_frontend.cpp",
"platform/default/src/mbgl/map/map_snapshotter.cpp",
+ "platform/default/src/mbgl/platform/thread_pool.cpp",
"platform/default/src/mbgl/text/bidi.cpp",
- "platform/default/src/mbgl/util/default_thread_pool.cpp",
"platform/default/src/mbgl/util/png_writer.cpp",
- "platform/default/src/mbgl/util/shared_thread_pool.cpp",
"platform/default/src/mbgl/util/thread_local.cpp",
"platform/default/src/mbgl/util/utf.cpp"
],
@@ -26,9 +25,7 @@
"mbgl/gl/headless_backend.hpp": "platform/default/include/mbgl/gl/headless_backend.hpp",
"mbgl/gl/headless_frontend.hpp": "platform/default/include/mbgl/gl/headless_frontend.hpp",
"mbgl/map/map_snapshotter.hpp": "platform/default/include/mbgl/map/map_snapshotter.hpp",
- "mbgl/util/default_styles.hpp": "platform/default/include/mbgl/util/default_styles.hpp",
- "mbgl/util/default_thread_pool.hpp": "platform/default/include/mbgl/util/default_thread_pool.hpp",
- "mbgl/util/shared_thread_pool.hpp": "platform/default/include/mbgl/util/shared_thread_pool.hpp"
+ "mbgl/util/default_styles.hpp": "platform/default/include/mbgl/util/default_styles.hpp"
},
"private_headers": {
"CFHandle.hpp": "platform/darwin/src/CFHandle.hpp"
diff --git a/platform/ios/src/MGLMapView.mm b/platform/ios/src/MGLMapView.mm
index 59bb1c6666..bc7b5da9ef 100644
--- a/platform/ios/src/MGLMapView.mm
+++ b/platform/ios/src/MGLMapView.mm
@@ -10,7 +10,6 @@
#include <mbgl/map/mode.hpp>
#include <mbgl/util/platform.hpp>
#include <mbgl/storage/reachability.h>
-#include <mbgl/util/default_thread_pool.hpp>
#include <mbgl/storage/default_file_source.hpp>
#include <mbgl/storage/network_status.hpp>
#include <mbgl/style/style.hpp>
@@ -30,7 +29,6 @@
#include <mbgl/util/default_styles.hpp>
#include <mbgl/util/chrono.hpp>
#include <mbgl/util/run_loop.hpp>
-#include <mbgl/util/shared_thread_pool.hpp>
#include <mbgl/util/string.hpp>
#include <mbgl/util/projection.hpp>
@@ -272,8 +270,6 @@ public:
MBGLView *_mbglView;
std::unique_ptr<MGLRenderFrontend> _rendererFrontend;
- std::shared_ptr<mbgl::ThreadPool> _mbglThreadPool;
-
BOOL _opaque;
MGLAnnotationTagContextMap _annotationContextsByAnnotationTag;
@@ -468,9 +464,8 @@ public:
// setup mbgl map
MGLRendererConfiguration *config = [MGLRendererConfiguration currentConfiguration];
- _mbglThreadPool = mbgl::sharedThreadPool();
- auto renderer = std::make_unique<mbgl::Renderer>(*_mbglView, config.scaleFactor, *config.fileSource, *_mbglThreadPool, config.contextMode, config.cacheDir, config.localFontFamilyName);
+ auto renderer = std::make_unique<mbgl::Renderer>(*_mbglView, config.scaleFactor, *config.fileSource, config.contextMode, config.cacheDir, config.localFontFamilyName);
BOOL enableCrossSourceCollisions = !config.perSourceCollisions;
_rendererFrontend = std::make_unique<MGLRenderFrontend>(std::move(renderer), self, *_mbglView);
@@ -481,7 +476,7 @@ public:
.withCrossSourceCollisions(enableCrossSourceCollisions);
NSAssert(!_mbglMap, @"_mbglMap should be NULL");
- _mbglMap = new mbgl::Map(*_rendererFrontend, *_mbglView, self.size, config.scaleFactor, *[config fileSource], *_mbglThreadPool, mapOptions);
+ _mbglMap = new mbgl::Map(*_rendererFrontend, *_mbglView, self.size, config.scaleFactor, *[config fileSource], mapOptions);
// start paused if in IB
if (_isTargetingInterfaceBuilder || background) {
@@ -739,7 +734,6 @@ public:
_mbglView = nullptr;
_rendererFrontend.reset();
- _mbglThreadPool.reset();
}
- (void)dealloc
diff --git a/platform/linux/config.cmake b/platform/linux/config.cmake
index 6d4715e451..ef987533d8 100644
--- a/platform/linux/config.cmake
+++ b/platform/linux/config.cmake
@@ -74,9 +74,7 @@ macro(mbgl_platform_core)
PRIVATE platform/default/include/mbgl/map/map_snapshotter.hpp
# Thread pool
- PRIVATE platform/default/src/mbgl/util/default_thread_pool.cpp
- PRIVATE platform/default/src/mbgl/util/default_thread_pool.cpp
- PRIVATE platform/default/src/mbgl/util/shared_thread_pool.cpp
+ PRIVATE platform/default/src/mbgl/platform/thread_pool.cpp
)
target_include_directories(mbgl-core
diff --git a/platform/macos/core-files.json b/platform/macos/core-files.json
index 9ec41f651a..eb9357bedb 100644
--- a/platform/macos/core-files.json
+++ b/platform/macos/core-files.json
@@ -12,10 +12,9 @@
"platform/default/src/mbgl/gl/headless_backend.cpp",
"platform/default/src/mbgl/gl/headless_frontend.cpp",
"platform/default/src/mbgl/map/map_snapshotter.cpp",
+ "platform/default/src/mbgl/platform/thread_pool.cpp",
"platform/default/src/mbgl/text/bidi.cpp",
- "platform/default/src/mbgl/util/default_thread_pool.cpp",
"platform/default/src/mbgl/util/png_writer.cpp",
- "platform/default/src/mbgl/util/shared_thread_pool.cpp",
"platform/default/src/mbgl/util/thread_local.cpp",
"platform/default/src/mbgl/util/utf.cpp"
],
@@ -24,9 +23,7 @@
"mbgl/util/image+MGLAdditions.hpp": "platform/darwin/include/mbgl/util/image+MGLAdditions.hpp",
"mbgl/gl/headless_backend.hpp": "platform/default/include/mbgl/gl/headless_backend.hpp",
"mbgl/gl/headless_frontend.hpp": "platform/default/include/mbgl/gl/headless_frontend.hpp",
- "mbgl/map/map_snapshotter.hpp": "platform/default/include/mbgl/map/map_snapshotter.hpp",
- "mbgl/util/default_thread_pool.hpp": "platform/default/include/mbgl/util/default_thread_pool.hpp",
- "mbgl/util/shared_thread_pool.hpp": "platform/default/include/mbgl/util/shared_thread_pool.hpp"
+ "mbgl/map/map_snapshotter.hpp": "platform/default/include/mbgl/map/map_snapshotter.hpp"
},
"private_headers": {
"CFHandle.hpp": "platform/darwin/src/CFHandle.hpp"
diff --git a/platform/macos/src/MGLMapView.mm b/platform/macos/src/MGLMapView.mm
index 045a0c9f98..09fb37add3 100644
--- a/platform/macos/src/MGLMapView.mm
+++ b/platform/macos/src/MGLMapView.mm
@@ -31,7 +31,6 @@
#import <mbgl/annotation/annotation.hpp>
#import <mbgl/map/camera.hpp>
#import <mbgl/storage/reachability.h>
-#import <mbgl/util/default_thread_pool.hpp>
#import <mbgl/style/image.hpp>
#import <mbgl/renderer/renderer.hpp>
#import <mbgl/renderer/renderer_backend.hpp>
@@ -43,7 +42,6 @@
#import <mbgl/util/chrono.hpp>
#import <mbgl/util/exception.hpp>
#import <mbgl/util/run_loop.hpp>
-#import <mbgl/util/shared_thread_pool.hpp>
#import <mbgl/util/string.hpp>
#import <mbgl/util/projection.hpp>
@@ -164,7 +162,6 @@ public:
mbgl::Map *_mbglMap;
MGLMapViewImpl *_mbglView;
std::unique_ptr<MGLRenderFrontend> _rendererFrontend;
- std::shared_ptr<mbgl::ThreadPool> _mbglThreadPool;
NSPanGestureRecognizer *_panGestureRecognizer;
NSMagnificationGestureRecognizer *_magnificationGestureRecognizer;
@@ -283,10 +280,9 @@ public:
NSURL *legacyCacheURL = [cachesDirectoryURL URLByAppendingPathComponent:@"cache.db"];
[[NSFileManager defaultManager] removeItemAtURL:legacyCacheURL error:NULL];
- _mbglThreadPool = mbgl::sharedThreadPool();
MGLRendererConfiguration *config = [MGLRendererConfiguration currentConfiguration];
- auto renderer = std::make_unique<mbgl::Renderer>(*_mbglView, config.scaleFactor, *config.fileSource, *_mbglThreadPool, config.contextMode, config.cacheDir, config.localFontFamilyName);
+ auto renderer = std::make_unique<mbgl::Renderer>(*_mbglView, config.scaleFactor, *config.fileSource, config.contextMode, config.cacheDir, config.localFontFamilyName);
BOOL enableCrossSourceCollisions = !config.perSourceCollisions;
_rendererFrontend = std::make_unique<MGLRenderFrontend>(std::move(renderer), self, *_mbglView, true);
@@ -295,7 +291,7 @@ public:
.withConstrainMode(mbgl::ConstrainMode::None)
.withViewportMode(mbgl::ViewportMode::Default)
.withCrossSourceCollisions(enableCrossSourceCollisions);
- _mbglMap = new mbgl::Map(*_rendererFrontend, *_mbglView, self.size, config.scaleFactor, *config.fileSource, *_mbglThreadPool, mapOptions);
+ _mbglMap = new mbgl::Map(*_rendererFrontend, *_mbglView, self.size, config.scaleFactor, *config.fileSource, mapOptions);
// Install the OpenGL layer. Interface Builder’s synchronous drawing means
// we can’t display a map, so don’t even bother to have a map layer.
diff --git a/platform/node/src/node_map.cpp b/platform/node/src/node_map.cpp
index b12d3552a4..cb923428ac 100644
--- a/platform/node/src/node_map.cpp
+++ b/platform/node/src/node_map.cpp
@@ -615,14 +615,14 @@ void NodeMap::cancel() {
reinterpret_cast<NodeMap *>(h->data)->renderFinished();
});
- frontend = std::make_unique<mbgl::HeadlessFrontend>(mbgl::Size{ 256, 256 }, pixelRatio, *this, threadpool);
+ frontend = std::make_unique<mbgl::HeadlessFrontend>(mbgl::Size{ 256, 256 }, pixelRatio, *this);
mbgl::MapOptions options;
options.withMapMode(mode)
.withConstrainMode(mbgl::ConstrainMode::HeightOnly)
.withViewportMode(mbgl::ViewportMode::Default)
.withCrossSourceCollisions(crossSourceCollisions);
map = std::make_unique<mbgl::Map>(*frontend, mapObserver, frontend->getSize(), pixelRatio,
- *this, threadpool, options);
+ *this, options);
// FIXME: Reload the style after recreating the map. We need to find
// a better way of canceling an ongoing rendering on the core level
@@ -1200,13 +1200,12 @@ NodeMap::NodeMap(v8::Local<v8::Object> options)
: true;
}())
, mapObserver(NodeMapObserver())
- , frontend(std::make_unique<mbgl::HeadlessFrontend>(mbgl::Size { 256, 256 }, pixelRatio, *this, threadpool))
+ , frontend(std::make_unique<mbgl::HeadlessFrontend>(mbgl::Size { 256, 256 }, pixelRatio, *this))
, map(std::make_unique<mbgl::Map>(*frontend,
mapObserver,
frontend->getSize(),
pixelRatio,
*this,
- threadpool,
mbgl::MapOptions().withMapMode(mode)
.withConstrainMode(mbgl::ConstrainMode::HeightOnly)
.withViewportMode(mbgl::ViewportMode::Default)
diff --git a/platform/node/src/node_map.hpp b/platform/node/src/node_map.hpp
index b83a238681..9d9f7405b8 100644
--- a/platform/node/src/node_map.hpp
+++ b/platform/node/src/node_map.hpp
@@ -1,7 +1,5 @@
#pragma once
-#include "node_thread_pool.hpp"
-
#include <mbgl/map/map.hpp>
#include <mbgl/storage/file_source.hpp>
#include <mbgl/util/image.hpp>
@@ -83,7 +81,6 @@ public:
const float pixelRatio;
mbgl::MapMode mode;
bool crossSourceCollisions;
- NodeThreadPool threadpool;
NodeMapObserver mapObserver;
std::unique_ptr<mbgl::HeadlessFrontend> frontend;
std::unique_ptr<mbgl::Map> map;
diff --git a/platform/node/src/node_thread_pool.cpp b/platform/node/src/node_thread_pool.cpp
index 1f37565e8a..de403c605c 100644
--- a/platform/node/src/node_thread_pool.cpp
+++ b/platform/node/src/node_thread_pool.cpp
@@ -2,6 +2,7 @@
#include "util/async_queue.hpp"
#include <mbgl/actor/mailbox.hpp>
+#include <mbgl/platform/background_scheduler.hpp>
namespace node_mbgl {
@@ -35,3 +36,14 @@ void NodeThreadPool::Worker::WorkComplete() {
}
} // namespace node_mbgl
+
+namespace mbgl {
+namespace platform {
+
+Scheduler& GetBackgroundScheduler() {
+ static node_mbgl::NodeThreadPool pool;
+ return pool;
+}
+
+} // namespace platform
+} // namespace mbgl
diff --git a/platform/qt/qt.cmake b/platform/qt/qt.cmake
index 14f09007ac..2751ad1fad 100644
--- a/platform/qt/qt.cmake
+++ b/platform/qt/qt.cmake
@@ -18,10 +18,7 @@ set(MBGL_QT_CORE_FILES
PRIVATE platform/qt/src/headless_backend_qt.cpp
# Thread pool
- PRIVATE platform/default/src/mbgl/util/shared_thread_pool.cpp
- PRIVATE platform/default/include/mbgl/util/shared_thread_pool.hpp
- PRIVATE platform/default/src/mbgl/util/default_thread_pool.cpp
- PRIVATE platform/default/include/mbgl/util/default_thread_pool.hpp
+ PRIVATE platform/default/src/mbgl/platform/thread_pool.cpp
# Thread
PRIVATE platform/qt/src/thread_local.cpp
diff --git a/platform/qt/src/qmapboxgl.cpp b/platform/qt/src/qmapboxgl.cpp
index 49b0dc021c..7d3d722550 100644
--- a/platform/qt/src/qmapboxgl.cpp
+++ b/platform/qt/src/qmapboxgl.cpp
@@ -41,7 +41,6 @@
#include <mbgl/util/projection.hpp>
#include <mbgl/util/rapidjson.hpp>
#include <mbgl/util/run_loop.hpp>
-#include <mbgl/util/shared_thread_pool.hpp>
#include <mbgl/util/traits.hpp>
#include <mbgl/actor/scheduler.hpp>
@@ -1745,7 +1744,6 @@ void QMapboxGL::connectionEstablished()
QMapboxGLPrivate::QMapboxGLPrivate(QMapboxGL *q, const QMapboxGLSettings &settings, const QSize &size, qreal pixelRatio_)
: QObject(q)
, m_fileSourceObj(sharedDefaultFileSource(settings))
- , m_threadPool(mbgl::sharedThreadPool())
, m_mode(settings.contextMode())
, m_pixelRatio(pixelRatio_)
, m_localFontFamily(settings.localFontFamily())
@@ -1777,7 +1775,7 @@ QMapboxGLPrivate::QMapboxGLPrivate(QMapboxGL *q, const QMapboxGLSettings &settin
*this, // RendererFrontend
*m_mapObserver,
sanitizedSize(size),
- m_pixelRatio, *m_fileSourceObj, *m_threadPool,
+ m_pixelRatio, *m_fileSourceObj,
options);
// Needs to be Queued to give time to discard redundant draw calls via the `renderQueued` flag.
@@ -1826,7 +1824,6 @@ void QMapboxGLPrivate::createRenderer()
m_mapRenderer = std::make_unique<QMapboxGLMapRenderer>(
m_pixelRatio,
*m_fileSourceObj,
- *m_threadPool,
m_mode,
m_localFontFamily
);
diff --git a/platform/qt/src/qmapboxgl_map_renderer.cpp b/platform/qt/src/qmapboxgl_map_renderer.cpp
index 31b518e6d0..f6dbd4d91e 100644
--- a/platform/qt/src/qmapboxgl_map_renderer.cpp
+++ b/platform/qt/src/qmapboxgl_map_renderer.cpp
@@ -25,8 +25,8 @@ static auto *getScheduler() {
};
QMapboxGLMapRenderer::QMapboxGLMapRenderer(qreal pixelRatio,
- mbgl::DefaultFileSource &fs, mbgl::ThreadPool &tp, QMapboxGLSettings::GLContextMode mode, const QString &localFontFamily)
- : m_renderer(std::make_unique<mbgl::Renderer>(m_backend, pixelRatio, fs, tp, static_cast<mbgl::GLContextMode>(mode), mbgl::optional<std::string> {},
+ mbgl::DefaultFileSource &fs, QMapboxGLSettings::GLContextMode mode, const QString &localFontFamily)
+ : m_renderer(std::make_unique<mbgl::Renderer>(m_backend, pixelRatio, fs, static_cast<mbgl::GLContextMode>(mode), mbgl::optional<std::string> {},
localFontFamily.isEmpty() ? mbgl::nullopt : mbgl::optional<std::string> { localFontFamily.toStdString() }))
, m_forceScheduler(needsToForceScheduler())
{
diff --git a/platform/qt/src/qmapboxgl_map_renderer.hpp b/platform/qt/src/qmapboxgl_map_renderer.hpp
index a59cf74997..e6f25c85d1 100644
--- a/platform/qt/src/qmapboxgl_map_renderer.hpp
+++ b/platform/qt/src/qmapboxgl_map_renderer.hpp
@@ -7,7 +7,6 @@
#include <mbgl/renderer/renderer_backend.hpp>
#include <mbgl/renderer/renderer_observer.hpp>
#include <mbgl/storage/default_file_source.hpp>
-#include <mbgl/util/shared_thread_pool.hpp>
#include <mbgl/util/util.hpp>
#include <QtGlobal>
@@ -28,7 +27,7 @@ class QMapboxGLMapRenderer : public QObject
public:
QMapboxGLMapRenderer(qreal pixelRatio, mbgl::DefaultFileSource &,
- mbgl::ThreadPool &, QMapboxGLSettings::GLContextMode,
+ QMapboxGLSettings::GLContextMode,
const QString &localFontFamily);
virtual ~QMapboxGLMapRenderer();
diff --git a/platform/qt/src/qmapboxgl_p.hpp b/platform/qt/src/qmapboxgl_p.hpp
index 7157df0aba..694671ef94 100644
--- a/platform/qt/src/qmapboxgl_p.hpp
+++ b/platform/qt/src/qmapboxgl_p.hpp
@@ -9,7 +9,6 @@
#include <mbgl/renderer/renderer_frontend.hpp>
#include <mbgl/storage/default_file_source.hpp>
#include <mbgl/storage/resource_transform.hpp>
-#include <mbgl/util/default_thread_pool.hpp>
#include <mbgl/util/geo.hpp>
#include <QObject>
@@ -58,7 +57,6 @@ private:
std::unique_ptr<QMapboxGLMapObserver> m_mapObserver;
std::shared_ptr<mbgl::DefaultFileSource> m_fileSourceObj;
- std::shared_ptr<mbgl::ThreadPool> m_threadPool;
std::unique_ptr<QMapboxGLMapRenderer> m_mapRenderer;
std::unique_ptr<mbgl::Actor<mbgl::ResourceTransform>> m_resourceTransform;
diff --git a/platform/qt/src/qmapboxgl_renderer_backend.hpp b/platform/qt/src/qmapboxgl_renderer_backend.hpp
index de66b035fc..6554016349 100644
--- a/platform/qt/src/qmapboxgl_renderer_backend.hpp
+++ b/platform/qt/src/qmapboxgl_renderer_backend.hpp
@@ -4,7 +4,6 @@
#include <mbgl/renderer/renderer_backend.hpp>
#include <mbgl/storage/default_file_source.hpp>
-#include <mbgl/util/shared_thread_pool.hpp>
class QMapboxGLRendererBackend : public mbgl::RendererBackend
{
diff --git a/src/mbgl/map/map.cpp b/src/mbgl/map/map.cpp
index 556038d2d8..5bc7a37332 100644
--- a/src/mbgl/map/map.cpp
+++ b/src/mbgl/map/map.cpp
@@ -17,7 +17,6 @@
#include <mbgl/util/exception.hpp>
#include <mbgl/util/mapbox.hpp>
#include <mbgl/util/tile_coordinate.hpp>
-#include <mbgl/actor/scheduler.hpp>
#include <mbgl/util/logging.hpp>
#include <mbgl/math/log2.hpp>
@@ -32,13 +31,11 @@ Map::Map(RendererFrontend& rendererFrontend,
const Size size,
const float pixelRatio,
FileSource& fileSource,
- Scheduler& scheduler,
const MapOptions& options)
: impl(std::make_unique<Impl>(*this,
rendererFrontend,
mapObserver,
fileSource,
- scheduler,
size,
pixelRatio,
options.mapMode(),
diff --git a/src/mbgl/map/map_impl.cpp b/src/mbgl/map/map_impl.cpp
index fc67d3cf56..04200c267f 100644
--- a/src/mbgl/map/map_impl.cpp
+++ b/src/mbgl/map/map_impl.cpp
@@ -9,7 +9,6 @@ Map::Impl::Impl(Map& map_,
RendererFrontend& frontend,
MapObserver& mapObserver,
FileSource& fileSource_,
- Scheduler& scheduler_,
Size size_,
float pixelRatio_,
MapMode mode_,
@@ -20,14 +19,13 @@ Map::Impl::Impl(Map& map_,
observer(mapObserver),
rendererFrontend(frontend),
fileSource(fileSource_),
- scheduler(scheduler_),
transform(observer,
constrainMode_,
viewportMode_),
mode(mode_),
pixelRatio(pixelRatio_),
crossSourceCollisions(crossSourceCollisions_),
- style(std::make_unique<style::Style>(scheduler, fileSource, pixelRatio)),
+ style(std::make_unique<style::Style>(fileSource, pixelRatio)),
annotationManager(*style) {
style->impl->setObserver(this);
diff --git a/src/mbgl/map/map_impl.hpp b/src/mbgl/map/map_impl.hpp
index 32dc728b70..598b72907a 100644
--- a/src/mbgl/map/map_impl.hpp
+++ b/src/mbgl/map/map_impl.hpp
@@ -1,6 +1,5 @@
#pragma once
-#include <mbgl/actor/scheduler.hpp>
#include <mbgl/annotation/annotation_manager.hpp>
#include <mbgl/map/map.hpp>
#include <mbgl/map/map_observer.hpp>
@@ -30,7 +29,6 @@ public:
RendererFrontend&,
MapObserver&,
FileSource&,
- Scheduler&,
Size size,
float pixelRatio,
@@ -61,7 +59,6 @@ public:
MapObserver& observer;
RendererFrontend& rendererFrontend;
FileSource& fileSource;
- Scheduler& scheduler;
Transform transform;
diff --git a/src/mbgl/renderer/renderer.cpp b/src/mbgl/renderer/renderer.cpp
index 5a92a675c5..c8be1d16ef 100644
--- a/src/mbgl/renderer/renderer.cpp
+++ b/src/mbgl/renderer/renderer.cpp
@@ -10,11 +10,10 @@ namespace mbgl {
Renderer::Renderer(RendererBackend& backend,
float pixelRatio_,
FileSource& fileSource_,
- Scheduler& scheduler_,
GLContextMode contextMode_,
const optional<std::string> programCacheDir_,
const optional<std::string> localFontFamily_)
- : impl(std::make_unique<Impl>(backend, pixelRatio_, fileSource_, scheduler_,
+ : impl(std::make_unique<Impl>(backend, pixelRatio_, fileSource_,
contextMode_, std::move(programCacheDir_), std::move(localFontFamily_))) {
}
diff --git a/src/mbgl/renderer/renderer_impl.cpp b/src/mbgl/renderer/renderer_impl.cpp
index aee7a243d4..bfd518c11b 100644
--- a/src/mbgl/renderer/renderer_impl.cpp
+++ b/src/mbgl/renderer/renderer_impl.cpp
@@ -38,12 +38,10 @@ static RendererObserver& nullObserver() {
Renderer::Impl::Impl(RendererBackend& backend_,
float pixelRatio_,
FileSource& fileSource_,
- Scheduler& scheduler_,
GLContextMode contextMode_,
const optional<std::string> programCacheDir_,
const optional<std::string> localFontFamily_)
: backend(backend_)
- , scheduler(scheduler_)
, fileSource(fileSource_)
, observer(&nullObserver())
, contextMode(contextMode_)
@@ -111,7 +109,6 @@ void Renderer::Impl::render(const UpdateParameters& updateParameters) {
updateParameters.pixelRatio,
updateParameters.debugOptions,
updateParameters.transformState,
- scheduler,
fileSource,
updateParameters.mode,
updateParameters.annotationManager,
diff --git a/src/mbgl/renderer/renderer_impl.hpp b/src/mbgl/renderer/renderer_impl.hpp
index 4555ba27d5..d820a50789 100644
--- a/src/mbgl/renderer/renderer_impl.hpp
+++ b/src/mbgl/renderer/renderer_impl.hpp
@@ -28,7 +28,6 @@ class RenderStaticData;
class RenderedQueryOptions;
class SourceQueryOptions;
class FileSource;
-class Scheduler;
class GlyphManager;
class ImageManager;
class LineAtlas;
@@ -37,7 +36,7 @@ class CrossTileSymbolIndex;
class Renderer::Impl : public GlyphManagerObserver,
public RenderSourceObserver{
public:
- Impl(RendererBackend&, float pixelRatio_, FileSource&, Scheduler&, GLContextMode,
+ Impl(RendererBackend&, float pixelRatio_, FileSource&, GLContextMode,
const optional<std::string> programCacheDir, const optional<std::string> localFontFamily);
~Impl() final;
@@ -90,7 +89,6 @@ private:
friend class Renderer;
RendererBackend& backend;
- Scheduler& scheduler;
FileSource& fileSource;
RendererObserver* observer;
diff --git a/src/mbgl/renderer/tile_parameters.hpp b/src/mbgl/renderer/tile_parameters.hpp
index 665c7490d2..cbe8dfb3ba 100644
--- a/src/mbgl/renderer/tile_parameters.hpp
+++ b/src/mbgl/renderer/tile_parameters.hpp
@@ -5,7 +5,6 @@
namespace mbgl {
class TransformState;
-class Scheduler;
class FileSource;
class AnnotationManager;
class ImageManager;
@@ -16,7 +15,6 @@ public:
const float pixelRatio;
const MapDebugOptions debugOptions;
const TransformState& transformState;
- Scheduler& workerScheduler;
FileSource& fileSource;
const MapMode mode;
AnnotationManager& annotationManager;
diff --git a/src/mbgl/sprite/sprite_loader.cpp b/src/mbgl/sprite/sprite_loader.cpp
index df4fe6e8df..d38d7a2715 100644
--- a/src/mbgl/sprite/sprite_loader.cpp
+++ b/src/mbgl/sprite/sprite_loader.cpp
@@ -20,9 +20,9 @@ namespace mbgl {
static SpriteLoaderObserver nullObserver;
struct SpriteLoader::Loader {
- Loader(Scheduler& scheduler, SpriteLoader& imageManager)
+ Loader(SpriteLoader& imageManager)
: mailbox(std::make_shared<Mailbox>(*Scheduler::GetCurrent())),
- worker(scheduler, ActorRef<SpriteLoader>(imageManager, mailbox)) {
+ worker(Scheduler::GetBackground(), ActorRef<SpriteLoader>(imageManager, mailbox)) {
}
std::shared_ptr<const std::string> image;
@@ -40,14 +40,14 @@ SpriteLoader::SpriteLoader(float pixelRatio_)
SpriteLoader::~SpriteLoader() = default;
-void SpriteLoader::load(const std::string& url, Scheduler& scheduler, FileSource& fileSource) {
+void SpriteLoader::load(const std::string& url, FileSource& fileSource) {
if (url.empty()) {
// Treat a non-existent sprite as a successfully loaded empty sprite.
observer->onSpriteLoaded({});
return;
}
- loader = std::make_unique<Loader>(scheduler, *this);
+ loader = std::make_unique<Loader>(*this);
loader->jsonRequest = fileSource.request(Resource::spriteJSON(url, pixelRatio), [this](Response res) {
if (res.error) {
diff --git a/src/mbgl/sprite/sprite_loader.hpp b/src/mbgl/sprite/sprite_loader.hpp
index 0daf46be9c..0b7d37fa14 100644
--- a/src/mbgl/sprite/sprite_loader.hpp
+++ b/src/mbgl/sprite/sprite_loader.hpp
@@ -12,7 +12,6 @@
namespace mbgl {
-class Scheduler;
class FileSource;
class SpriteLoaderObserver;
@@ -21,7 +20,7 @@ public:
SpriteLoader(float pixelRatio);
~SpriteLoader();
- void load(const std::string& url, Scheduler&, FileSource&);
+ void load(const std::string& url, FileSource&);
void setObserver(SpriteLoaderObserver*);
diff --git a/src/mbgl/style/sources/custom_geometry_source.cpp b/src/mbgl/style/sources/custom_geometry_source.cpp
index 6ce7c1be11..6e9d8d65fb 100644
--- a/src/mbgl/style/sources/custom_geometry_source.cpp
+++ b/src/mbgl/style/sources/custom_geometry_source.cpp
@@ -4,7 +4,6 @@
#include <mbgl/actor/actor.hpp>
#include <mbgl/actor/scheduler.hpp>
#include <mbgl/tile/tile_id.hpp>
-#include <mbgl/util/shared_thread_pool.hpp>
#include <tuple>
#include <map>
@@ -14,7 +13,7 @@ namespace style {
CustomGeometrySource::CustomGeometrySource(std::string id,
const CustomGeometrySource::Options options)
: Source(makeMutable<CustomGeometrySource::Impl>(std::move(id), options)),
- loader(std::make_unique<Actor<CustomTileLoader>>(*sharedThreadPool(), options.fetchTileFunction, options.cancelTileFunction)) {
+ loader(std::make_unique<Actor<CustomTileLoader>>(Scheduler::GetBackground(), options.fetchTileFunction, options.cancelTileFunction)) {
}
CustomGeometrySource::~CustomGeometrySource() = default;
diff --git a/src/mbgl/style/style.cpp b/src/mbgl/style/style.cpp
index bd8631fc52..783c850097 100644
--- a/src/mbgl/style/style.cpp
+++ b/src/mbgl/style/style.cpp
@@ -8,8 +8,8 @@
namespace mbgl {
namespace style {
-Style::Style(Scheduler& scheduler, FileSource& fileSource, float pixelRatio)
- : impl(std::make_unique<Impl>(scheduler, fileSource, pixelRatio)) {
+Style::Style(FileSource& fileSource, float pixelRatio)
+ : impl(std::make_unique<Impl>(fileSource, pixelRatio)) {
}
Style::~Style() = default;
diff --git a/src/mbgl/style/style_impl.cpp b/src/mbgl/style/style_impl.cpp
index d65e9c9de2..ebddfbcb22 100644
--- a/src/mbgl/style/style_impl.cpp
+++ b/src/mbgl/style/style_impl.cpp
@@ -27,9 +27,8 @@ namespace style {
static Observer nullObserver;
-Style::Impl::Impl(Scheduler& scheduler_, FileSource& fileSource_, float pixelRatio)
- : scheduler(scheduler_),
- fileSource(fileSource_),
+Style::Impl::Impl(FileSource& fileSource_, float pixelRatio)
+ : fileSource(fileSource_),
spriteLoader(std::make_unique<SpriteLoader>(pixelRatio)),
light(std::make_unique<Light>()),
observer(&nullObserver) {
@@ -111,7 +110,7 @@ void Style::Impl::parse(const std::string& json_) {
setLight(std::make_unique<Light>(parser.light));
spriteLoaded = false;
- spriteLoader->load(parser.spriteURL, scheduler, fileSource);
+ spriteLoader->load(parser.spriteURL, fileSource);
glyphURL = parser.glyphURL;
loaded = true;
diff --git a/src/mbgl/style/style_impl.hpp b/src/mbgl/style/style_impl.hpp
index 3dc222bfad..4c56f6785b 100644
--- a/src/mbgl/style/style_impl.hpp
+++ b/src/mbgl/style/style_impl.hpp
@@ -25,7 +25,6 @@
namespace mbgl {
-class Scheduler;
class FileSource;
class AsyncRequest;
class SpriteLoader;
@@ -38,7 +37,7 @@ class Style::Impl : public SpriteLoaderObserver,
public LightObserver,
public util::noncopyable {
public:
- Impl(Scheduler&, FileSource&, float pixelRatio);
+ Impl(FileSource&, float pixelRatio);
~Impl() override;
void loadJSON(const std::string&);
@@ -98,7 +97,6 @@ public:
private:
void parse(const std::string&);
- Scheduler& scheduler;
FileSource& fileSource;
std::string url;
diff --git a/src/mbgl/tile/geometry_tile.cpp b/src/mbgl/tile/geometry_tile.cpp
index 977744248d..fb571e2979 100644
--- a/src/mbgl/tile/geometry_tile.cpp
+++ b/src/mbgl/tile/geometry_tile.cpp
@@ -1,4 +1,5 @@
#include <mbgl/tile/geometry_tile.hpp>
+
#include <mbgl/tile/geometry_tile_worker.hpp>
#include <mbgl/tile/geometry_tile_data.hpp>
#include <mbgl/tile/tile_observer.hpp>
@@ -45,7 +46,7 @@ GeometryTile::GeometryTile(const OverscaledTileID& id_,
: Tile(Kind::Geometry, id_),
sourceID(std::move(sourceID_)),
mailbox(std::make_shared<Mailbox>(*Scheduler::GetCurrent())),
- worker(parameters.workerScheduler,
+ worker(Scheduler::GetBackground(),
ActorRef<GeometryTile>(*this, mailbox),
id_,
sourceID,
diff --git a/src/mbgl/tile/raster_dem_tile.cpp b/src/mbgl/tile/raster_dem_tile.cpp
index 751f69bad9..b451c85728 100644
--- a/src/mbgl/tile/raster_dem_tile.cpp
+++ b/src/mbgl/tile/raster_dem_tile.cpp
@@ -1,4 +1,5 @@
#include <mbgl/tile/raster_dem_tile.hpp>
+
#include <mbgl/tile/raster_dem_tile_worker.hpp>
#include <mbgl/tile/tile_observer.hpp>
#include <mbgl/tile/tile_loader_impl.hpp>
@@ -18,7 +19,7 @@ RasterDEMTile::RasterDEMTile(const OverscaledTileID& id_,
: Tile(Kind::RasterDEM, id_),
loader(*this, id_, parameters, tileset),
mailbox(std::make_shared<Mailbox>(*Scheduler::GetCurrent())),
- worker(parameters.workerScheduler,
+ worker(Scheduler::GetBackground(),
ActorRef<RasterDEMTile>(*this, mailbox)) {
encoding = tileset.encoding;
diff --git a/src/mbgl/tile/raster_tile.cpp b/src/mbgl/tile/raster_tile.cpp
index 1346f87ae5..3a415bbb80 100644
--- a/src/mbgl/tile/raster_tile.cpp
+++ b/src/mbgl/tile/raster_tile.cpp
@@ -1,4 +1,5 @@
#include <mbgl/tile/raster_tile.hpp>
+
#include <mbgl/tile/raster_tile_worker.hpp>
#include <mbgl/tile/tile_observer.hpp>
#include <mbgl/tile/tile_loader_impl.hpp>
@@ -18,7 +19,7 @@ RasterTile::RasterTile(const OverscaledTileID& id_,
: Tile(Kind::Raster, id_),
loader(*this, id_, parameters, tileset),
mailbox(std::make_shared<Mailbox>(*Scheduler::GetCurrent())),
- worker(parameters.workerScheduler,
+ worker(Scheduler::GetBackground(),
ActorRef<RasterTile>(*this, mailbox)) {
}
diff --git a/test/actor/actor.test.cpp b/test/actor/actor.test.cpp
index 7493abe263..a2266cd7a2 100644
--- a/test/actor/actor.test.cpp
+++ b/test/actor/actor.test.cpp
@@ -1,5 +1,4 @@
#include <mbgl/actor/actor.hpp>
-#include <mbgl/util/default_thread_pool.hpp>
#include <mbgl/util/run_loop.hpp>
#include <mbgl/test/util.hpp>
@@ -20,9 +19,8 @@ TEST(Actor, Construction) {
};
};
- ThreadPool pool { 1 };
bool constructed = false;
- Actor<Test> test(pool, std::ref(constructed));
+ Actor<Test> test(Scheduler::GetBackground(), std::ref(constructed));
EXPECT_TRUE(constructed);
}
@@ -37,10 +35,9 @@ TEST(Actor, Destruction) {
bool& destructed;
};
- ThreadPool pool { 1 };
bool destructed = false;
{
- Actor<Test> test(pool, std::ref(destructed));
+ Actor<Test> test(Scheduler::GetBackground(), std::ref(destructed));
}
EXPECT_TRUE(destructed);
@@ -72,15 +69,13 @@ TEST(Actor, DestructionBlocksOnReceive) {
}
};
- ThreadPool pool { 1 };
-
std::promise<void> enteredPromise;
std::future<void> enteredFuture = enteredPromise.get_future();
std::promise<void> exitingPromise;
std::future<void> exitingFuture = exitingPromise.get_future();
- Actor<Test> test(pool, std::move(enteredPromise), std::move(exitingFuture));
+ Actor<Test> test(Scheduler::GetBackground(), std::move(enteredPromise), std::move(exitingFuture));
test.self().invoke(&Test::wait);
enteredFuture.wait();
@@ -157,11 +152,8 @@ TEST(Actor, DestructionAllowedInReceiveOnSameThread) {
}
};
- ThreadPool pool { 1 };
-
std::promise<void> callbackFiredPromise;
-
- auto test = std::make_unique<Actor<Test>>(pool);
+ auto test = std::make_unique<Actor<Test>>(Scheduler::GetBackground());
// Callback (triggered while mutex is locked in Mailbox::receive())
test->self().invoke(&Test::callMeBack, [&]() {
@@ -189,12 +181,10 @@ TEST(Actor, SelfDestructionDoesntCrashWaitingReceivingThreads) {
};
- ThreadPool pool { 2 };
-
std::promise<void> actorClosedPromise;
- auto closingActor = std::make_unique<Actor<Test>>(pool);
- auto waitingActor = std::make_unique<Actor<Test>>(pool);
+ auto closingActor = std::make_unique<Actor<Test>>(Scheduler::GetBackground());
+ auto waitingActor = std::make_unique<Actor<Test>>(Scheduler::GetBackground());
std::atomic<bool> waitingMessageProcessed {false};
@@ -251,11 +241,9 @@ TEST(Actor, OrderedMailbox) {
}
};
- ThreadPool pool { 1 };
-
std::promise<void> endedPromise;
std::future<void> endedFuture = endedPromise.get_future();
- Actor<Test> test(pool, std::move(endedPromise));
+ Actor<Test> test(Scheduler::GetBackground(), std::move(endedPromise));
for (auto i = 1; i <= 10; ++i) {
test.self().invoke(&Test::receive, i);
@@ -287,11 +275,9 @@ TEST(Actor, NonConcurrentMailbox) {
}
};
- ThreadPool pool { 10 };
-
std::promise<void> endedPromise;
std::future<void> endedFuture = endedPromise.get_future();
- Actor<Test> test(pool, std::move(endedPromise));
+ Actor<Test> test(Scheduler::GetBackground(), std::move(endedPromise));
for (auto i = 1; i <= 10; ++i) {
test.self().invoke(&Test::receive, i);
@@ -313,8 +299,7 @@ TEST(Actor, Ask) {
}
};
- ThreadPool pool { 2 };
- Actor<Test> test(pool);
+ Actor<Test> test(Scheduler::GetBackground());
auto result = test.self().ask(&Test::doubleIt, 1);
@@ -339,9 +324,8 @@ TEST(Actor, AskVoid) {
}
};
- ThreadPool pool { 1 };
bool executed = false;
- Actor<Test> actor(pool, executed);
+ Actor<Test> actor(Scheduler::GetBackground(), executed);
actor.self().ask(&Test::doIt).get();
EXPECT_TRUE(executed);
@@ -353,8 +337,7 @@ TEST(Actor, NoSelfActorRef) {
// Trivially constructable
struct Trivial {};
- ThreadPool pool { 2 };
- Actor<Trivial> trivial(pool);
+ Actor<Trivial> trivial(Scheduler::GetBackground());
// With arguments
@@ -372,7 +355,7 @@ TEST(Actor, NoSelfActorRef) {
std::promise<void> promise;
auto future = promise.get_future();
- Actor<WithArguments> withArguments(pool, std::move(promise));
+ Actor<WithArguments> withArguments(Scheduler::GetBackground(), std::move(promise));
withArguments.self().invoke(&WithArguments::receive);
future.wait();
diff --git a/test/actor/actor_ref.test.cpp b/test/actor/actor_ref.test.cpp
index 20aa1c35c1..221a220ed9 100644
--- a/test/actor/actor_ref.test.cpp
+++ b/test/actor/actor_ref.test.cpp
@@ -1,6 +1,6 @@
#include <mbgl/actor/actor.hpp>
-#include <mbgl/util/default_thread_pool.hpp>
+#include <mbgl/actor/scheduler.hpp>
#include <mbgl/test/util.hpp>
#include <future>
@@ -27,11 +27,10 @@ TEST(ActorRef, CanOutliveActor) {
}
};
- ThreadPool pool { 1 };
bool died = false;
ActorRef<Test> test = [&] () {
- return Actor<Test>(pool, std::ref(died)).self();
+ return Actor<Test>(Scheduler::GetBackground(), std::ref(died)).self();
}();
EXPECT_TRUE(died);
@@ -54,8 +53,7 @@ TEST(ActorRef, Ask) {
}
};
- ThreadPool pool { 1 };
- Actor<Test> actor(pool);
+ Actor<Test> actor(Scheduler::GetBackground());
ActorRef<Test> ref = actor.self();
EXPECT_EQ(20, ref.ask(&Test::gimme).get());
@@ -76,9 +74,8 @@ TEST(ActorRef, AskVoid) {
}
};
- ThreadPool pool { 1 };
bool executed = false;
- Actor<Test> actor(pool, executed);
+ Actor<Test> actor(Scheduler::GetBackground(), executed);
ActorRef<Test> ref = actor.self();
ref.ask(&Test::doIt).get();
@@ -104,8 +101,7 @@ TEST(ActorRef, AskOnDestroyedActor) {
};
bool died = false;
- ThreadPool pool { 1 };
- auto actor = std::make_unique<Actor<Test>>(pool, died);
+ auto actor = std::make_unique<Actor<Test>>(Scheduler::GetBackground(), died);
ActorRef<Test> ref = actor->self();
actor.reset();
diff --git a/test/api/annotations.test.cpp b/test/api/annotations.test.cpp
index a81d9ff990..a67e691f69 100644
--- a/test/api/annotations.test.cpp
+++ b/test/api/annotations.test.cpp
@@ -1,7 +1,6 @@
#include <mbgl/test/util.hpp>
#include <mbgl/test/stub_file_source.hpp>
-#include <mbgl/util/default_thread_pool.hpp>
#include <mbgl/annotation/annotation.hpp>
#include <mbgl/style/style.hpp>
#include <mbgl/style/image.hpp>
@@ -29,12 +28,11 @@ class AnnotationTest {
public:
util::RunLoop loop;
StubFileSource fileSource;
- ThreadPool threadPool { 4 };
float pixelRatio { 1 };
- HeadlessFrontend frontend { pixelRatio, fileSource, threadPool };
+ HeadlessFrontend frontend { pixelRatio, fileSource };
Map map { frontend, MapObserver::nullObserver(), frontend.getSize(), pixelRatio, fileSource,
- threadPool, MapOptions().withMapMode(MapMode::Static)};
+ MapOptions().withMapMode(MapMode::Static)};
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 8899173071..9490c14e1f 100644
--- a/test/api/api_misuse.test.cpp
+++ b/test/api/api_misuse.test.cpp
@@ -7,7 +7,6 @@
#include <mbgl/renderer/backend_scope.hpp>
#include <mbgl/gl/headless_frontend.hpp>
#include <mbgl/storage/online_file_source.hpp>
-#include <mbgl/util/default_thread_pool.hpp>
#include <mbgl/util/exception.hpp>
#include <mbgl/util/run_loop.hpp>
@@ -23,12 +22,11 @@ TEST(API, RenderWithoutCallback) {
util::RunLoop loop;
StubFileSource fileSource;
- ThreadPool threadPool(4);
float pixelRatio { 1 };
- HeadlessFrontend frontend { pixelRatio, fileSource, threadPool };
+ HeadlessFrontend frontend { pixelRatio, fileSource };
auto map = std::make_unique<Map>(frontend, MapObserver::nullObserver(), frontend.getSize(),
- pixelRatio, fileSource, threadPool,
+ pixelRatio, fileSource,
MapOptions().withMapMode(MapMode::Static));
map->renderStill(nullptr);
diff --git a/test/api/custom_geometry_source.test.cpp b/test/api/custom_geometry_source.test.cpp
index 4eeca9104b..54df2e5cfb 100644
--- a/test/api/custom_geometry_source.test.cpp
+++ b/test/api/custom_geometry_source.test.cpp
@@ -2,7 +2,6 @@
#include <mbgl/map/map.hpp>
#include <mbgl/map/map_options.hpp>
-#include <mbgl/util/shared_thread_pool.hpp>
#include <mbgl/storage/default_file_source.hpp>
#include <mbgl/gl/headless_frontend.hpp>
#include <mbgl/style/style.hpp>
@@ -21,11 +20,10 @@ TEST(CustomGeometrySource, Grid) {
util::RunLoop loop;
DefaultFileSource fileSource(":memory:", "test/fixtures/api/assets");
- auto threadPool = sharedThreadPool();
float pixelRatio { 1 };
- HeadlessFrontend frontend { pixelRatio, fileSource, *threadPool };
+ HeadlessFrontend frontend { pixelRatio, fileSource };
Map map(frontend, MapObserver::nullObserver(), frontend.getSize(), pixelRatio, fileSource,
- *threadPool, MapOptions().withMapMode(MapMode::Static));
+ MapOptions().withMapMode(MapMode::Static));
map.getStyle().loadJSON(util::read_file("test/fixtures/api/water.json"));
map.jumpTo(CameraOptions().withCenter(LatLng { 37.8, -122.5 }).withZoom(10.0));
diff --git a/test/api/custom_layer.test.cpp b/test/api/custom_layer.test.cpp
index d840925206..7ea5f57cd8 100644
--- a/test/api/custom_layer.test.cpp
+++ b/test/api/custom_layer.test.cpp
@@ -3,7 +3,6 @@
#include <mbgl/platform/gl_functions.hpp>
#include <mbgl/map/map.hpp>
#include <mbgl/map/map_options.hpp>
-#include <mbgl/util/default_thread_pool.hpp>
#include <mbgl/storage/default_file_source.hpp>
#include <mbgl/gl/defines.hpp>
#include <mbgl/gl/headless_frontend.hpp>
@@ -91,11 +90,10 @@ TEST(CustomLayer, Basic) {
util::RunLoop loop;
DefaultFileSource fileSource(":memory:", "test/fixtures/api/assets");
- ThreadPool threadPool(4);
float pixelRatio { 1 };
- HeadlessFrontend frontend { pixelRatio, fileSource, threadPool };
+ HeadlessFrontend frontend { pixelRatio, fileSource };
Map map(frontend, MapObserver::nullObserver(), frontend.getSize(), pixelRatio, fileSource,
- threadPool, MapOptions().withMapMode(MapMode::Static));
+ MapOptions().withMapMode(MapMode::Static));
map.getStyle().loadJSON(util::read_file("test/fixtures/api/water.json"));
map.jumpTo(CameraOptions().withCenter(LatLng { 37.8, -122.5 }).withZoom(10.0));
map.getStyle().addLayer(std::make_unique<CustomLayer>(
diff --git a/test/api/query.test.cpp b/test/api/query.test.cpp
index b9fc3a4a62..b7359e4e60 100644
--- a/test/api/query.test.cpp
+++ b/test/api/query.test.cpp
@@ -1,6 +1,5 @@
#include <mbgl/map/map.hpp>
#include <mbgl/map/map_options.hpp>
-#include <mbgl/util/default_thread_pool.hpp>
#include <mbgl/test/stub_file_source.hpp>
#include <mbgl/test/util.hpp>
#include <mbgl/util/image.hpp>
@@ -34,11 +33,10 @@ public:
util::RunLoop loop;
StubFileSource fileSource;
- ThreadPool threadPool { 4 };
float pixelRatio { 1 };
- HeadlessFrontend frontend { pixelRatio, fileSource, threadPool };
+ HeadlessFrontend frontend { pixelRatio, fileSource };
Map map { frontend, MapObserver::nullObserver(), frontend.getSize(), pixelRatio, fileSource,
- threadPool, MapOptions().withMapMode(MapMode::Static)};
+ MapOptions().withMapMode(MapMode::Static)};
};
std::vector<Feature> getTopClusterFeature(QueryTest& test) {
diff --git a/test/api/recycle_map.cpp b/test/api/recycle_map.cpp
index 0883241274..5598dfbd85 100644
--- a/test/api/recycle_map.cpp
+++ b/test/api/recycle_map.cpp
@@ -10,7 +10,6 @@
#include <mbgl/style/sources/geojson_source.hpp>
#include <mbgl/style/image.hpp>
#include <mbgl/style/style.hpp>
-#include <mbgl/util/default_thread_pool.hpp>
#include <mbgl/util/exception.hpp>
#include <mbgl/util/geometry.hpp>
#include <mbgl/util/geojson.hpp>
@@ -25,12 +24,11 @@ TEST(API, RecycleMapUpdateImages) {
util::RunLoop loop;
StubFileSource fileSource;
- ThreadPool threadPool(4);
float pixelRatio { 1 };
- HeadlessFrontend frontend { pixelRatio, fileSource, threadPool };
+ HeadlessFrontend frontend { pixelRatio, fileSource };
auto map = std::make_unique<Map>(frontend, MapObserver::nullObserver(), frontend.getSize(),
- pixelRatio, fileSource, threadPool,
+ pixelRatio, fileSource,
MapOptions().withMapMode(MapMode::Static));
EXPECT_TRUE(map);
diff --git a/test/gl/context.test.cpp b/test/gl/context.test.cpp
index f260555f55..5703792a7d 100644
--- a/test/gl/context.test.cpp
+++ b/test/gl/context.test.cpp
@@ -4,7 +4,6 @@
#include <mbgl/gl/context.hpp>
#include <mbgl/map/map.hpp>
#include <mbgl/map/map_options.hpp>
-#include <mbgl/util/default_thread_pool.hpp>
#include <mbgl/storage/default_file_source.hpp>
#include <mbgl/gl/defines.hpp>
#include <mbgl/gl/headless_frontend.hpp>
@@ -87,13 +86,12 @@ TEST(GLContextMode, Shared) {
util::RunLoop loop;
DefaultFileSource fileSource(":memory:", "test/fixtures/api/assets");
- ThreadPool threadPool(4);
float pixelRatio { 1 };
- HeadlessFrontend frontend { pixelRatio, fileSource, threadPool, {}, GLContextMode::Shared };
+ HeadlessFrontend frontend { pixelRatio, fileSource, {}, GLContextMode::Shared };
Map map(frontend, MapObserver::nullObserver(), frontend.getSize(), pixelRatio,
- fileSource, threadPool, MapOptions().withMapMode(MapMode::Static));
+ fileSource, MapOptions().withMapMode(MapMode::Static));
map.getStyle().loadJSON(util::read_file("test/fixtures/api/water.json"));
map.jumpTo(CameraOptions().withCenter(LatLng { 37.8, -122.5 }).withZoom(10.0));
diff --git a/test/map/map.test.cpp b/test/map/map.test.cpp
index f45c728944..ecbb92d164 100644
--- a/test/map/map.test.cpp
+++ b/test/map/map.test.cpp
@@ -8,7 +8,6 @@
#include <mbgl/map/map_options.hpp>
#include <mbgl/gl/context.hpp>
#include <mbgl/gl/headless_frontend.hpp>
-#include <mbgl/util/default_thread_pool.hpp>
#include <mbgl/storage/network_status.hpp>
#include <mbgl/storage/default_file_source.hpp>
#include <mbgl/storage/online_file_source.hpp>
@@ -32,15 +31,14 @@ class MapTest {
public:
util::RunLoop runLoop;
FileSource fileSource;
- ThreadPool threadPool { 4 };
StubMapObserver observer;
HeadlessFrontend frontend;
Map map;
MapTest(float pixelRatio = 1, MapMode mode = MapMode::Static)
- : frontend(pixelRatio, fileSource, threadPool)
+ : frontend(pixelRatio, fileSource)
, map(frontend, observer, frontend.getSize(), pixelRatio,
- fileSource, threadPool, MapOptions().withMapMode(mode)) {
+ fileSource, MapOptions().withMapMode(mode)) {
}
template <typename T = FileSource>
@@ -48,9 +46,9 @@ public:
float pixelRatio = 1, MapMode mode = MapMode::Static,
typename std::enable_if<std::is_same<T, DefaultFileSource>::value>::type* = 0)
: fileSource { cachePath, assetRoot }
- , frontend(pixelRatio, fileSource, threadPool)
+ , frontend(pixelRatio, fileSource)
, map(frontend, observer, frontend.getSize(), pixelRatio,
- fileSource, threadPool, MapOptions().withMapMode(mode)) {
+ fileSource, MapOptions().withMapMode(mode)) {
}
};
@@ -671,7 +669,6 @@ TEST(Map, DontLoadUnneededTiles) {
TEST(Map, TEST_DISABLED_ON_CI(ContinuousRendering)) {
util::RunLoop runLoop;
- ThreadPool threadPool { 4 };
DefaultFileSource fileSource(":memory:", "test/fixtures/api/assets");
float pixelRatio { 1 };
@@ -685,7 +682,7 @@ TEST(Map, TEST_DISABLED_ON_CI(ContinuousRendering)) {
util::Timer timer;
- HeadlessFrontend frontend(pixelRatio, fileSource, threadPool);
+ HeadlessFrontend frontend(pixelRatio, fileSource);
StubMapObserver observer;
observer.didFinishRenderingFrameCallback = [&] (MapObserver::RenderMode) {
@@ -698,7 +695,7 @@ TEST(Map, TEST_DISABLED_ON_CI(ContinuousRendering)) {
};
Map map(frontend, observer, frontend.getSize(), pixelRatio, fileSource,
- threadPool, MapOptions().withMapMode(MapMode::Continuous));
+ MapOptions().withMapMode(MapMode::Continuous));
map.getStyle().loadJSON(util::read_file("test/fixtures/api/water.json"));
runLoop.run();
diff --git a/test/map/prefetch.test.cpp b/test/map/prefetch.test.cpp
index 9b7d620739..ba1bd5258e 100644
--- a/test/map/prefetch.test.cpp
+++ b/test/map/prefetch.test.cpp
@@ -7,7 +7,6 @@
#include <mbgl/gl/headless_frontend.hpp>
#include <mbgl/storage/default_file_source.hpp>
#include <mbgl/style/style.hpp>
-#include <mbgl/util/default_thread_pool.hpp>
#include <mbgl/util/image.hpp>
#include <mbgl/util/io.hpp>
#include <mbgl/util/run_loop.hpp>
@@ -23,7 +22,6 @@ using namespace std::chrono_literals;
TEST(Map, PrefetchTiles) {
util::RunLoop runLoop;
- ThreadPool threadPool(4);
StubFileSource fileSource;
util::Timer emergencyShutoff;
@@ -37,8 +35,8 @@ TEST(Map, PrefetchTiles) {
runLoop.stop();
};
- HeadlessFrontend frontend { { 512, 512 }, 1, fileSource, threadPool };
- Map map(frontend, observer, frontend.getSize(), 1, fileSource, threadPool,
+ HeadlessFrontend frontend { { 512, 512 }, 1, fileSource };
+ Map map(frontend, observer, frontend.getSize(), 1, fileSource,
MapOptions().withMapMode(MapMode::Continuous));
std::vector<int> tiles;
diff --git a/test/renderer/image_manager.test.cpp b/test/renderer/image_manager.test.cpp
index 4a838d0f9c..eecec38430 100644
--- a/test/renderer/image_manager.test.cpp
+++ b/test/renderer/image_manager.test.cpp
@@ -9,7 +9,6 @@
#include <mbgl/util/io.hpp>
#include <mbgl/util/image.hpp>
#include <mbgl/util/run_loop.hpp>
-#include <mbgl/util/default_thread_pool.hpp>
#include <mbgl/util/string.hpp>
#include <utility>
diff --git a/test/sprite/sprite_loader.test.cpp b/test/sprite/sprite_loader.test.cpp
index 3691572265..122e711f51 100644
--- a/test/sprite/sprite_loader.test.cpp
+++ b/test/sprite/sprite_loader.test.cpp
@@ -8,7 +8,6 @@
#include <mbgl/util/io.hpp>
#include <mbgl/util/image.hpp>
#include <mbgl/util/run_loop.hpp>
-#include <mbgl/util/default_thread_pool.hpp>
#include <mbgl/util/string.hpp>
#include <utility>
@@ -37,7 +36,6 @@ public:
util::RunLoop loop;
StubFileSource fileSource;
StubSpriteLoaderObserver observer;
- ThreadPool threadPool { 1 };
SpriteLoader spriteLoader{ 1 };
void run() {
@@ -45,7 +43,7 @@ public:
Log::setObserver(std::make_unique<Log::NullObserver>());
spriteLoader.setObserver(&observer);
- spriteLoader.load("test/fixtures/resources/sprite", threadPool, fileSource);
+ spriteLoader.load("test/fixtures/resources/sprite", fileSource);
loop.run();
}
diff --git a/test/style/source.test.cpp b/test/style/source.test.cpp
index 8bc152926f..73212189de 100644
--- a/test/style/source.test.cpp
+++ b/test/style/source.test.cpp
@@ -28,7 +28,6 @@
#include <mbgl/util/image.hpp>
#include <mbgl/util/tileset.hpp>
-#include <mbgl/util/shared_thread_pool.hpp>
#include <mbgl/util/logging.hpp>
#include <mbgl/util/optional.hpp>
#include <mbgl/util/range.hpp>
@@ -52,8 +51,7 @@ public:
StubRenderSourceObserver renderSourceObserver;
Transform transform;
TransformState transformState;
- ThreadPool threadPool { 1 };
- Style style { loop, fileSource, 1 };
+ Style style { fileSource, 1 };
AnnotationManager annotationManager { style };
ImageManager imageManager;
GlyphManager glyphManager { fileSource };
@@ -62,7 +60,6 @@ public:
1.0,
MapDebugOptions(),
transformState,
- threadPool,
fileSource,
MapMode::Continuous,
annotationManager,
@@ -746,7 +743,6 @@ TEST(Source, ImageSourceImageUpdate) {
TEST(Source, CustomGeometrySourceSetTileData) {
SourceTest test;
- std::shared_ptr<ThreadPool> threadPool = sharedThreadPool();
CustomGeometrySource source("source", CustomGeometrySource::Options());
source.loadDescription(test.fileSource);
diff --git a/test/style/style.test.cpp b/test/style/style.test.cpp
index 7f57651331..72f74d3b01 100644
--- a/test/style/style.test.cpp
+++ b/test/style/style.test.cpp
@@ -9,7 +9,6 @@
#include <mbgl/style/layers/line_layer.hpp>
#include <mbgl/util/io.hpp>
#include <mbgl/util/run_loop.hpp>
-#include <mbgl/util/default_thread_pool.hpp>
#include <memory>
@@ -19,9 +18,8 @@ using namespace mbgl::style;
TEST(Style, Properties) {
util::RunLoop loop;
- ThreadPool threadPool{ 1 };
StubFileSource fileSource;
- Style::Impl style { threadPool, fileSource, 1.0 };
+ Style::Impl style { fileSource, 1.0 };
style.loadJSON(R"STYLE({"name": "Test"})STYLE");
ASSERT_EQ("Test", style.getName());
@@ -62,9 +60,8 @@ TEST(Style, Properties) {
TEST(Style, DuplicateSource) {
util::RunLoop loop;
- ThreadPool threadPool{ 1 };
StubFileSource fileSource;
- Style::Impl style { threadPool, fileSource, 1.0 };
+ Style::Impl style { fileSource, 1.0 };
style.loadJSON(util::read_file("test/fixtures/resources/style-unused-sources.json"));
@@ -84,9 +81,8 @@ TEST(Style, RemoveSourceInUse) {
auto log = new FixtureLogObserver();
Log::setObserver(std::unique_ptr<Log::Observer>(log));
- ThreadPool threadPool{ 1 };
StubFileSource fileSource;
- Style::Impl style { threadPool, fileSource, 1.0 };
+ Style::Impl style { fileSource, 1.0 };
style.loadJSON(util::read_file("test/fixtures/resources/style-unused-sources.json"));
diff --git a/test/style/style_layer.test.cpp b/test/style/style_layer.test.cpp
index 50aa643b50..5f9de07dba 100644
--- a/test/style/style_layer.test.cpp
+++ b/test/style/style_layer.test.cpp
@@ -18,7 +18,6 @@
#include <mbgl/style/layers/symbol_layer_impl.hpp>
#include <mbgl/util/color.hpp>
#include <mbgl/util/run_loop.hpp>
-#include <mbgl/util/default_thread_pool.hpp>
#include <mbgl/util/io.hpp>
#include <memory>
@@ -273,9 +272,8 @@ TEST(Layer, DuplicateLayer) {
util::RunLoop loop;
// Setup style
- ThreadPool threadPool{ 1 };
StubFileSource fileSource;
- Style::Impl style { threadPool, fileSource, 1.0 };
+ Style::Impl style { fileSource, 1.0 };
style.loadJSON(util::read_file("test/fixtures/resources/style-unused-sources.json"));
// Add initial layer
diff --git a/test/text/local_glyph_rasterizer.test.cpp b/test/text/local_glyph_rasterizer.test.cpp
index 20f825c935..5c03945b8c 100644
--- a/test/text/local_glyph_rasterizer.test.cpp
+++ b/test/text/local_glyph_rasterizer.test.cpp
@@ -7,7 +7,6 @@
#include <mbgl/util/color.hpp>
#include <mbgl/renderer/renderer.hpp>
#include <mbgl/gl/headless_frontend.hpp>
-#include <mbgl/util/default_thread_pool.hpp>
#include <mbgl/style/style.hpp>
/*
@@ -33,17 +32,16 @@ namespace {
class LocalGlyphRasterizerTest {
public:
LocalGlyphRasterizerTest(const optional<std::string> fontFamily)
- : frontend(pixelRatio, fileSource, threadPool, optional<std::string>(), GLContextMode::Unique, fontFamily)
+ : frontend(pixelRatio, fileSource, optional<std::string>(), GLContextMode::Unique, fontFamily)
{
}
util::RunLoop loop;
StubFileSource fileSource;
- ThreadPool threadPool { 4 };
float pixelRatio { 1 };
HeadlessFrontend frontend;
Map map { frontend, MapObserver::nullObserver(), frontend.getSize(), pixelRatio, fileSource,
- threadPool, MapOptions().withMapMode(MapMode::Static)};
+ MapOptions().withMapMode(MapMode::Static)};
void checkRendering(const char * name) {
test::checkImage(std::string("test/fixtures/local_glyphs/") + name,
diff --git a/test/tile/custom_geometry_tile.test.cpp b/test/tile/custom_geometry_tile.test.cpp
index dc6aaab1ac..834f02879b 100644
--- a/test/tile/custom_geometry_tile.test.cpp
+++ b/test/tile/custom_geometry_tile.test.cpp
@@ -5,7 +5,6 @@
#include <mbgl/tile/custom_geometry_tile.hpp>
#include <mbgl/style/custom_tile_loader.hpp>
-#include <mbgl/util/default_thread_pool.hpp>
#include <mbgl/util/run_loop.hpp>
#include <mbgl/map/transform.hpp>
#include <mbgl/renderer/tile_parameters.hpp>
@@ -25,8 +24,7 @@ public:
FakeFileSource fileSource;
TransformState transformState;
util::RunLoop loop;
- ThreadPool threadPool { 1 };
- style::Style style { loop, fileSource, 1 };
+ style::Style style { fileSource, 1 };
AnnotationManager annotationManager { style };
ImageManager imageManager;
GlyphManager glyphManager { fileSource };
@@ -35,7 +33,6 @@ public:
1.0,
MapDebugOptions(),
transformState,
- threadPool,
fileSource,
MapMode::Continuous,
annotationManager,
diff --git a/test/tile/geojson_tile.test.cpp b/test/tile/geojson_tile.test.cpp
index fb5f3ca6d7..e68103f4a0 100644
--- a/test/tile/geojson_tile.test.cpp
+++ b/test/tile/geojson_tile.test.cpp
@@ -4,7 +4,6 @@
#include <mbgl/tile/geojson_tile.hpp>
#include <mbgl/tile/tile_loader_impl.hpp>
-#include <mbgl/util/default_thread_pool.hpp>
#include <mbgl/util/run_loop.hpp>
#include <mbgl/map/transform.hpp>
#include <mbgl/renderer/tile_parameters.hpp>
@@ -24,8 +23,7 @@ public:
FakeFileSource fileSource;
TransformState transformState;
util::RunLoop loop;
- ThreadPool threadPool { 1 };
- style::Style style { loop, fileSource, 1 };
+ style::Style style { fileSource, 1 };
AnnotationManager annotationManager { style };
ImageManager imageManager;
GlyphManager glyphManager { fileSource };
@@ -35,7 +33,6 @@ public:
1.0,
MapDebugOptions(),
transformState,
- threadPool,
fileSource,
MapMode::Continuous,
annotationManager,
diff --git a/test/tile/raster_dem_tile.test.cpp b/test/tile/raster_dem_tile.test.cpp
index 5a6f5a8c9a..e2e7d44b9b 100644
--- a/test/tile/raster_dem_tile.test.cpp
+++ b/test/tile/raster_dem_tile.test.cpp
@@ -4,7 +4,6 @@
#include <mbgl/tile/tile_loader_impl.hpp>
#include <mbgl/style/style.hpp>
-#include <mbgl/util/default_thread_pool.hpp>
#include <mbgl/util/run_loop.hpp>
#include <mbgl/map/transform.hpp>
#include <mbgl/annotation/annotation_manager.hpp>
@@ -20,8 +19,7 @@ public:
FakeFileSource fileSource;
TransformState transformState;
util::RunLoop loop;
- ThreadPool threadPool { 1 };
- style::Style style { loop, fileSource, 1 };
+ style::Style style { fileSource, 1 };
AnnotationManager annotationManager { style };
ImageManager imageManager;
GlyphManager glyphManager { fileSource };
@@ -31,7 +29,6 @@ public:
1.0,
MapDebugOptions(),
transformState,
- threadPool,
fileSource,
MapMode::Continuous,
annotationManager,
diff --git a/test/tile/raster_tile.test.cpp b/test/tile/raster_tile.test.cpp
index 8b2b3dee61..2e35a94025 100644
--- a/test/tile/raster_tile.test.cpp
+++ b/test/tile/raster_tile.test.cpp
@@ -4,7 +4,6 @@
#include <mbgl/tile/tile_loader_impl.hpp>
#include <mbgl/style/style.hpp>
-#include <mbgl/util/default_thread_pool.hpp>
#include <mbgl/util/run_loop.hpp>
#include <mbgl/map/transform.hpp>
#include <mbgl/annotation/annotation_manager.hpp>
@@ -20,8 +19,7 @@ public:
FakeFileSource fileSource;
TransformState transformState;
util::RunLoop loop;
- ThreadPool threadPool { 1 };
- style::Style style { loop, fileSource, 1 };
+ style::Style style { fileSource, 1 };
AnnotationManager annotationManager { style };
ImageManager imageManager;
GlyphManager glyphManager { fileSource };
@@ -31,7 +29,6 @@ public:
1.0,
MapDebugOptions(),
transformState,
- threadPool,
fileSource,
MapMode::Continuous,
annotationManager,
diff --git a/test/tile/vector_tile.test.cpp b/test/tile/vector_tile.test.cpp
index ed3eda7863..c610d8c1a7 100644
--- a/test/tile/vector_tile.test.cpp
+++ b/test/tile/vector_tile.test.cpp
@@ -4,7 +4,6 @@
#include <mbgl/tile/vector_tile_data.hpp>
#include <mbgl/tile/tile_loader_impl.hpp>
-#include <mbgl/util/default_thread_pool.hpp>
#include <mbgl/util/run_loop.hpp>
#include <mbgl/map/transform.hpp>
#include <mbgl/style/style.hpp>
@@ -26,8 +25,7 @@ public:
FakeFileSource fileSource;
TransformState transformState;
util::RunLoop loop;
- ThreadPool threadPool { 1 };
- style::Style style { loop, fileSource, 1 };
+ style::Style style { fileSource, 1 };
AnnotationManager annotationManager { style };
ImageManager imageManager;
GlyphManager glyphManager { fileSource };
@@ -37,7 +35,6 @@ public:
1.0,
MapDebugOptions(),
transformState,
- threadPool,
fileSource,
MapMode::Continuous,
annotationManager,
diff --git a/test/util/async_task.test.cpp b/test/util/async_task.test.cpp
index f3025e8952..46fbf65ca3 100644
--- a/test/util/async_task.test.cpp
+++ b/test/util/async_task.test.cpp
@@ -1,14 +1,14 @@
#include <mbgl/util/async_task.hpp>
-#include <mbgl/util/run_loop.hpp>
-#include <mbgl/util/default_thread_pool.hpp>
-#include <mbgl/actor/actor_ref.hpp>
+#include <mbgl/actor/actor_ref.hpp>
+#include <mbgl/util/run_loop.hpp>
#include <mbgl/test/util.hpp>
#include <atomic>
#include <future>
#include <vector>
+using namespace mbgl;
using namespace mbgl::util;
namespace {
@@ -104,11 +104,10 @@ TEST(AsyncTask, RequestCoalescingMultithreaded) {
unsigned count = 0, numThreads = 25;
AsyncTask async([&count] { ++count; });
- mbgl::ThreadPool threads(numThreads);
- auto mailbox = std::make_shared<mbgl::Mailbox>(threads);
+ auto mailbox = std::make_shared<Mailbox>(Scheduler::GetBackground());
TestWorker worker(&async);
- mbgl::ActorRef<TestWorker> workerRef(worker, mailbox);
+ ActorRef<TestWorker> workerRef(worker, mailbox);
for (unsigned i = 0; i < numThreads; ++i) {
workerRef.invoke(&TestWorker::run);
@@ -133,11 +132,10 @@ TEST(AsyncTask, ThreadSafety) {
AsyncTask async([&count] { ++count; });
- mbgl::ThreadPool threads(numThreads);
- auto mailbox = std::make_shared<mbgl::Mailbox>(threads);
+ auto mailbox = std::make_shared<Mailbox>(Scheduler::GetBackground());
TestWorker worker(&async);
- mbgl::ActorRef<TestWorker> workerRef(worker, mailbox);
+ ActorRef<TestWorker> workerRef(worker, mailbox);
for (unsigned i = 0; i < numThreads; ++i) {
// The callback runs on the worker, thus the atomic type.
diff --git a/test/util/memory.test.cpp b/test/util/memory.test.cpp
index a0e64a6704..b64e05124f 100644
--- a/test/util/memory.test.cpp
+++ b/test/util/memory.test.cpp
@@ -5,7 +5,6 @@
#include <mbgl/map/map.hpp>
#include <mbgl/map/map_options.hpp>
#include <mbgl/gl/headless_frontend.hpp>
-#include <mbgl/util/default_thread_pool.hpp>
#include <mbgl/util/io.hpp>
#include <mbgl/util/run_loop.hpp>
#include <mbgl/style/style.hpp>
@@ -36,7 +35,6 @@ public:
util::RunLoop runLoop;
StubFileSource fileSource;
- ThreadPool threadPool { 4 };
private:
Response response(const std::string& path) {
@@ -71,9 +69,9 @@ TEST(Memory, Vector) {
MemoryTest test;
float ratio { 2 };
- HeadlessFrontend frontend { { 256, 256 }, ratio, test.fileSource, test.threadPool };
+ HeadlessFrontend frontend { { 256, 256 }, ratio, test.fileSource };
Map map(frontend, MapObserver::nullObserver(), frontend.getSize(), ratio, test.fileSource,
- test.threadPool, MapOptions().withMapMode(MapMode::Static));
+ MapOptions().withMapMode(MapMode::Static));
map.jumpTo(CameraOptions().withZoom(16));
map.getStyle().loadURL("mapbox://streets");
@@ -84,9 +82,9 @@ TEST(Memory, Raster) {
MemoryTest test;
float ratio { 2 };
- HeadlessFrontend frontend { { 256, 256 }, ratio, test.fileSource, test.threadPool };
+ HeadlessFrontend frontend { { 256, 256 }, ratio, test.fileSource };
Map map(frontend, MapObserver::nullObserver(), frontend.getSize(), ratio, test.fileSource,
- test.threadPool, MapOptions().withMapMode(MapMode::Static));
+ MapOptions().withMapMode(MapMode::Static));
map.getStyle().loadURL("mapbox://satellite");
frontend.render(map);
@@ -122,9 +120,9 @@ TEST(Memory, Footprint) {
class FrontendAndMap {
public:
FrontendAndMap(MemoryTest& test_, const char* style)
- : frontend(Size{ 256, 256 }, 2, test_.fileSource, test_.threadPool)
- , map(frontend, MapObserver::nullObserver(), frontend.getSize(), 2, test_.fileSource
- , test_.threadPool, MapOptions().withMapMode(MapMode::Static)) {
+ : frontend(Size{ 256, 256 }, 2, test_.fileSource)
+ , map(frontend, MapObserver::nullObserver(), frontend.getSize(), 2, test_.fileSource,
+ MapOptions().withMapMode(MapMode::Static)) {
map.jumpTo(CameraOptions().withZoom(16));
map.getStyle().loadURL(style);
frontend.render(map);
diff --git a/test/util/thread.test.cpp b/test/util/thread.test.cpp
index 2bcb9d8959..70a3e8ff68 100644
--- a/test/util/thread.test.cpp
+++ b/test/util/thread.test.cpp
@@ -1,8 +1,8 @@
+#include <mbgl/util/thread.hpp>
+
#include <mbgl/actor/actor_ref.hpp>
#include <mbgl/test/util.hpp>
-#include <mbgl/util/default_thread_pool.hpp>
#include <mbgl/util/run_loop.hpp>
-#include <mbgl/util/thread.hpp>
#include <mbgl/util/timer.hpp>
#include <atomic>
@@ -139,8 +139,7 @@ TEST(Thread, Concurrency) {
unsigned numMessages = 100000;
std::atomic_uint completed(numMessages);
- ThreadPool threadPool(10);
- Actor<TestWorker> poolWorker(threadPool);
+ Actor<TestWorker> poolWorker(Scheduler::GetBackground());
auto poolWorkerRef = poolWorker.self();
Thread<TestWorker> threadedObject("Test");
@@ -165,8 +164,7 @@ TEST(Thread, Concurrency) {
TEST(Thread, ThreadPoolMessaging) {
auto loop = std::make_shared<RunLoop>();
- ThreadPool threadPool(1);
- Actor<TestWorker> poolWorker(threadPool);
+ Actor<TestWorker> poolWorker(Scheduler::GetBackground());
auto poolWorkerRef = poolWorker.self();
Thread<TestWorker> threadedObject("Test");