[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`.
This commit is contained in:
@@ -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>
|
||||
@@ -30,9 +29,8 @@ public:
|
||||
}
|
||||
|
||||
util::RunLoop loop;
|
||||
ThreadPool threadPool{ 4 };
|
||||
HeadlessFrontend frontend { { 1000, 1000 }, 1, threadPool };
|
||||
Map map { frontend, MapObserver::nullObserver(), threadPool,
|
||||
HeadlessFrontend frontend { { 1000, 1000 }, 1 };
|
||||
Map map { frontend, MapObserver::nullObserver(),
|
||||
MapOptions().withMapMode(MapMode::Static).withSize(frontend.getSize()),
|
||||
ResourceOptions().withCachePath("benchmark/fixtures/api/cache.db").withAssetPath(".").withAccessToken("foobar") };
|
||||
ScreenBox box{{ 0, 0 }, { 1000, 1000 }};
|
||||
|
||||
@@ -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>
|
||||
@@ -29,7 +28,6 @@ public:
|
||||
}
|
||||
|
||||
util::RunLoop loop;
|
||||
ThreadPool threadPool { 4 };
|
||||
};
|
||||
|
||||
static void prepare(Map& map, optional<std::string> json = {}) {
|
||||
@@ -44,8 +42,8 @@ static void prepare(Map& map, optional<std::string> json = {}) {
|
||||
|
||||
static void API_renderStill_reuse_map(::benchmark::State& state) {
|
||||
RenderBenchmark bench;
|
||||
HeadlessFrontend frontend { size, pixelRatio, bench.threadPool };
|
||||
Map map { frontend, MapObserver::nullObserver(), bench.threadPool,
|
||||
HeadlessFrontend frontend { size, pixelRatio };
|
||||
Map map { frontend, MapObserver::nullObserver(),
|
||||
MapOptions().withMapMode(MapMode::Static).withSize(size).withPixelRatio(pixelRatio),
|
||||
ResourceOptions().withCachePath(cachePath).withAccessToken("foobar") };
|
||||
prepare(map);
|
||||
@@ -57,8 +55,8 @@ static void API_renderStill_reuse_map(::benchmark::State& state) {
|
||||
|
||||
static void API_renderStill_reuse_map_formatted_labels(::benchmark::State& state) {
|
||||
RenderBenchmark bench;
|
||||
HeadlessFrontend frontend { size, pixelRatio, bench.threadPool };
|
||||
Map map { frontend, MapObserver::nullObserver(), bench.threadPool,
|
||||
HeadlessFrontend frontend { size, pixelRatio };
|
||||
Map map { frontend, MapObserver::nullObserver(),
|
||||
MapOptions().withMapMode(MapMode::Static).withSize(size).withPixelRatio(pixelRatio),
|
||||
ResourceOptions().withCachePath(cachePath).withAccessToken("foobar") };
|
||||
prepare(map, util::read_file("benchmark/fixtures/api/style_formatted_labels.json"));
|
||||
@@ -70,8 +68,8 @@ static void API_renderStill_reuse_map_formatted_labels(::benchmark::State& state
|
||||
|
||||
static void API_renderStill_reuse_map_switch_styles(::benchmark::State& state) {
|
||||
RenderBenchmark bench;
|
||||
HeadlessFrontend frontend { size, pixelRatio, bench.threadPool };
|
||||
Map map { frontend, MapObserver::nullObserver(), bench.threadPool,
|
||||
HeadlessFrontend frontend { size, pixelRatio };
|
||||
Map map { frontend, MapObserver::nullObserver(),
|
||||
MapOptions().withMapMode(MapMode::Static).withSize(size).withPixelRatio(pixelRatio),
|
||||
ResourceOptions().withCachePath(cachePath).withAccessToken("foobar") };
|
||||
|
||||
@@ -87,8 +85,8 @@ static void API_renderStill_recreate_map(::benchmark::State& state) {
|
||||
RenderBenchmark bench;
|
||||
|
||||
while (state.KeepRunning()) {
|
||||
HeadlessFrontend frontend { size, pixelRatio, bench.threadPool };
|
||||
Map map { frontend, MapObserver::nullObserver(), bench.threadPool,
|
||||
HeadlessFrontend frontend { size, pixelRatio };
|
||||
Map map { frontend, MapObserver::nullObserver(),
|
||||
MapOptions().withMapMode(MapMode::Static).withSize(size).withPixelRatio(pixelRatio),
|
||||
ResourceOptions().withCachePath(cachePath).withAccessToken("foobar") };
|
||||
prepare(map);
|
||||
|
||||
@@ -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/style/style.hpp>
|
||||
|
||||
#include <args.hxx>
|
||||
@@ -76,9 +75,8 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
util::RunLoop loop;
|
||||
|
||||
ThreadPool threadPool(4);
|
||||
HeadlessFrontend frontend({ width, height }, pixelRatio, threadPool);
|
||||
Map map(frontend, MapObserver::nullObserver(), threadPool,
|
||||
HeadlessFrontend frontend({ width, height }, pixelRatio);
|
||||
Map map(frontend, MapObserver::nullObserver(),
|
||||
MapOptions().withMapMode(MapMode::Static).withSize(frontend.getSize()).withPixelRatio(pixelRatio),
|
||||
ResourceOptions().withCachePath(cache_file).withAssetPath(asset_root).withAccessToken(std::string(token)));
|
||||
|
||||
|
||||
@@ -55,6 +55,10 @@ public:
|
||||
Actor(Scheduler& scheduler, Args&&... args)
|
||||
: target(scheduler, parent, std::forward<Args>(args)...) {}
|
||||
|
||||
template <class... Args>
|
||||
Actor(std::shared_ptr<Scheduler> scheduler, Args&&... args)
|
||||
: retainer(std::move(scheduler)), target(*retainer, parent, std::forward<Args>(args)...) {}
|
||||
|
||||
Actor(const Actor&) = delete;
|
||||
|
||||
ActorRef<std::decay_t<Object>> self() {
|
||||
@@ -62,6 +66,7 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
std::shared_ptr<Scheduler> retainer;
|
||||
AspiringActor<Object> parent;
|
||||
EstablishedActor<Object> target;
|
||||
};
|
||||
|
||||
@@ -41,6 +41,11 @@ public:
|
||||
// Set/Get the current Scheduler for this thread
|
||||
static Scheduler* GetCurrent();
|
||||
static void SetCurrent(Scheduler*);
|
||||
|
||||
// Get the scheduler for asynchronous tasks. This method
|
||||
// will lazily initialize a shared worker pool when ran
|
||||
// from the first time.
|
||||
static std::shared_ptr<Scheduler> GetBackground();
|
||||
};
|
||||
|
||||
} // namespace mbgl
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
class Scheduler;
|
||||
class RendererFrontend;
|
||||
|
||||
namespace style {
|
||||
@@ -34,7 +33,6 @@ class Map : private util::noncopyable {
|
||||
public:
|
||||
explicit Map(RendererFrontend&,
|
||||
MapObserver&,
|
||||
Scheduler&,
|
||||
const MapOptions&,
|
||||
const ResourceOptions&);
|
||||
~Map();
|
||||
|
||||
@@ -14,7 +14,6 @@ namespace mbgl {
|
||||
|
||||
class RendererObserver;
|
||||
class RenderedQueryOptions;
|
||||
class Scheduler;
|
||||
class SourceQueryOptions;
|
||||
class UpdateParameters;
|
||||
|
||||
@@ -24,7 +23,7 @@ class RendererBackend;
|
||||
|
||||
class Renderer {
|
||||
public:
|
||||
Renderer(gfx::RendererBackend&, float pixelRatio_, Scheduler&,
|
||||
Renderer(gfx::RendererBackend&, float pixelRatio_,
|
||||
const optional<std::string> programCacheDir = {},
|
||||
const optional<std::string> localFontFamily = {});
|
||||
~Renderer();
|
||||
|
||||
@@ -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&);
|
||||
|
||||
@@ -89,9 +89,7 @@
|
||||
"platform/default/src/mbgl/gl/headless_frontend.cpp",
|
||||
"platform/default/src/mbgl/map/map_snapshotter.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 +99,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",
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
#include <mbgl/renderer/renderer.hpp>
|
||||
#include <mbgl/gfx/backend_scope.hpp>
|
||||
#include <mbgl/util/shared_thread_pool.hpp>
|
||||
#include <mbgl/util/run_loop.hpp>
|
||||
|
||||
#include <string>
|
||||
@@ -23,7 +22,6 @@ MapRenderer::MapRenderer(jni::JNIEnv& _env,
|
||||
, pixelRatio(pixelRatio_)
|
||||
, 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)) {
|
||||
}
|
||||
|
||||
@@ -175,7 +173,7 @@ void MapRenderer::onSurfaceCreated(JNIEnv&) {
|
||||
|
||||
// Create the new backend and renderer
|
||||
backend = std::make_unique<AndroidRendererBackend>();
|
||||
renderer = std::make_unique<Renderer>(*backend, pixelRatio, *threadPool, programCacheDir, localIdeographFontFamily);
|
||||
renderer = std::make_unique<Renderer>(*backend, pixelRatio, programCacheDir, localIdeographFontFamily);
|
||||
rendererRef = std::make_unique<ActorRef<Renderer>>(*renderer, mailbox);
|
||||
|
||||
// Set the observer on the new Renderer implementation
|
||||
|
||||
@@ -21,7 +21,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>
|
||||
@@ -66,8 +65,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) {
|
||||
@@ -89,7 +87,7 @@ NativeMapView::NativeMapView(jni::JNIEnv& _env,
|
||||
|
||||
// Create the core map
|
||||
map = std::make_unique<mbgl::Map>(
|
||||
*rendererFrontend, *this, *threadPool, options,
|
||||
*rendererFrontend, *this, options,
|
||||
mbgl::android::FileSource::getSharedResourceOptions(_env, jFileSource));
|
||||
}
|
||||
|
||||
|
||||
@@ -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/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;
|
||||
};
|
||||
|
||||
@@ -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) {
|
||||
@@ -58,8 +56,7 @@ MapSnapshotter::MapSnapshotter(jni::JNIEnv& _env,
|
||||
|
||||
showLogo = _showLogo;
|
||||
// Create the core snapshotter
|
||||
snapshotter = std::make_unique<mbgl::MapSnapshotter>(threadPool,
|
||||
style,
|
||||
snapshotter = std::make_unique<mbgl::MapSnapshotter>(style,
|
||||
size,
|
||||
pixelRatio,
|
||||
cameraOptions,
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -8,9 +8,7 @@
|
||||
#import <mbgl/map/camera.hpp>
|
||||
#import <mbgl/storage/resource_options.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"
|
||||
@@ -125,7 +123,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;
|
||||
}
|
||||
@@ -176,7 +173,6 @@ const CGFloat MGLSnapshotterMinimumPixelSize = 64;
|
||||
|
||||
_mbglMapSnapshotter.reset();
|
||||
_snapshotCallback.reset();
|
||||
_mbglThreadPool.reset();
|
||||
|
||||
self.terminated = YES;
|
||||
}
|
||||
@@ -591,8 +587,6 @@ const CGFloat MGLSnapshotterMinimumPixelSize = 64;
|
||||
_options = options;
|
||||
|
||||
auto 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);
|
||||
@@ -630,7 +624,7 @@ const CGFloat MGLSnapshotterMinimumPixelSize = 64;
|
||||
|
||||
// Create the snapshotter
|
||||
_mbglMapSnapshotter = std::make_unique<mbgl::MapSnapshotter>(
|
||||
_mbglThreadPool, style, size, pixelRatio, cameraOptions, coordinateBounds, config.cacheDir, config.localFontFamilyName, resourceOptions);
|
||||
style, size, pixelRatio, cameraOptions, coordinateBounds, config.cacheDir, config.localFontFamilyName, resourceOptions);
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
class Scheduler;
|
||||
class Renderer;
|
||||
class Map;
|
||||
class TransformState;
|
||||
@@ -22,13 +21,11 @@ class RendererBackend;
|
||||
class HeadlessFrontend : public RendererFrontend {
|
||||
public:
|
||||
HeadlessFrontend(float pixelRatio_,
|
||||
Scheduler&,
|
||||
const optional<std::string> programCacheDir = {},
|
||||
gfx::ContextMode mode = gfx::ContextMode::Unique,
|
||||
const optional<std::string> localFontFamily = {});
|
||||
HeadlessFrontend(Size,
|
||||
float pixelRatio_,
|
||||
Scheduler&,
|
||||
const optional<std::string> programCacheDir = {},
|
||||
gfx::ContextMode mode = gfx::ContextMode::Unique,
|
||||
const optional<std::string> localFontFamily = {});
|
||||
|
||||
@@ -26,8 +26,7 @@ class Style;
|
||||
|
||||
class MapSnapshotter {
|
||||
public:
|
||||
MapSnapshotter(std::shared_ptr<Scheduler> scheduler,
|
||||
const std::pair<bool, std::string> style,
|
||||
MapSnapshotter(const std::pair<bool, std::string> style,
|
||||
const Size&,
|
||||
const float pixelRatio,
|
||||
const optional<CameraOptions> cameraOptions,
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <mbgl/util/default_thread_pool.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
std::shared_ptr<ThreadPool> sharedThreadPool();
|
||||
|
||||
} // namespace mbgl
|
||||
@@ -10,17 +10,15 @@
|
||||
namespace mbgl {
|
||||
|
||||
HeadlessFrontend::HeadlessFrontend(float pixelRatio_,
|
||||
Scheduler& scheduler,
|
||||
const optional<std::string> programCacheDir,
|
||||
const gfx::ContextMode contextMode,
|
||||
const optional<std::string> localFontFamily)
|
||||
: HeadlessFrontend(
|
||||
{ 256, 256 }, pixelRatio_, scheduler, programCacheDir, contextMode, localFontFamily) {
|
||||
{ 256, 256 }, pixelRatio_, programCacheDir, contextMode, localFontFamily) {
|
||||
}
|
||||
|
||||
HeadlessFrontend::HeadlessFrontend(Size size_,
|
||||
float pixelRatio_,
|
||||
Scheduler& scheduler,
|
||||
const optional<std::string> programCacheDir,
|
||||
const gfx::ContextMode contextMode,
|
||||
const optional<std::string> localFontFamily)
|
||||
@@ -40,7 +38,7 @@ HeadlessFrontend::HeadlessFrontend(Size size_,
|
||||
renderer->render(*updateParameters_);
|
||||
}
|
||||
}),
|
||||
renderer(std::make_unique<Renderer>(backend, pixelRatio, scheduler, programCacheDir, localFontFamily)) {
|
||||
renderer(std::make_unique<Renderer>(backend, pixelRatio, programCacheDir, localFontFamily)) {
|
||||
}
|
||||
|
||||
HeadlessFrontend::~HeadlessFrontend() = default;
|
||||
|
||||
@@ -14,8 +14,7 @@ namespace mbgl {
|
||||
|
||||
class MapSnapshotter::Impl {
|
||||
public:
|
||||
Impl(std::shared_ptr<Scheduler>,
|
||||
const std::pair<bool, std::string> style,
|
||||
Impl(const std::pair<bool, std::string> style,
|
||||
const Size&,
|
||||
const float pixelRatio,
|
||||
const optional<CameraOptions> cameraOptions,
|
||||
@@ -42,13 +41,11 @@ public:
|
||||
void snapshot(ActorRef<MapSnapshotter::Callback>);
|
||||
|
||||
private:
|
||||
std::shared_ptr<Scheduler> scheduler;
|
||||
HeadlessFrontend frontend;
|
||||
Map map;
|
||||
};
|
||||
|
||||
MapSnapshotter::Impl::Impl(std::shared_ptr<Scheduler> scheduler_,
|
||||
const std::pair<bool, std::string> style,
|
||||
MapSnapshotter::Impl::Impl(const std::pair<bool, std::string> style,
|
||||
const Size& size,
|
||||
const float pixelRatio,
|
||||
const optional<CameraOptions> cameraOptions,
|
||||
@@ -56,12 +53,10 @@ MapSnapshotter::Impl::Impl(std::shared_ptr<Scheduler> scheduler_,
|
||||
const optional<std::string> programCacheDir,
|
||||
const optional<std::string> localFontFamily,
|
||||
const ResourceOptions& resourceOptions)
|
||||
: scheduler(std::move(scheduler_)),
|
||||
frontend(
|
||||
size, pixelRatio, *scheduler, programCacheDir, gfx::ContextMode::Unique, localFontFamily),
|
||||
: frontend(
|
||||
size, pixelRatio, programCacheDir, gfx::ContextMode::Unique, localFontFamily),
|
||||
map(frontend,
|
||||
MapObserver::nullObserver(),
|
||||
*scheduler,
|
||||
MapOptions().withMapMode(MapMode::Static).withSize(size).withPixelRatio(pixelRatio),
|
||||
resourceOptions) {
|
||||
if (style.first) {
|
||||
@@ -168,8 +163,7 @@ LatLngBounds MapSnapshotter::Impl::getRegion() const {
|
||||
return map.latLngBoundsForCamera(getCameraOptions());
|
||||
}
|
||||
|
||||
MapSnapshotter::MapSnapshotter(std::shared_ptr<Scheduler> scheduler,
|
||||
const std::pair<bool, std::string> style,
|
||||
MapSnapshotter::MapSnapshotter(const std::pair<bool, std::string> style,
|
||||
const Size& size,
|
||||
const float pixelRatio,
|
||||
const optional<CameraOptions> cameraOptions,
|
||||
@@ -178,7 +172,7 @@ MapSnapshotter::MapSnapshotter(std::shared_ptr<Scheduler> scheduler,
|
||||
const optional<std::string> localFontFamily,
|
||||
const ResourceOptions& resourceOptions)
|
||||
: impl(std::make_unique<util::Thread<MapSnapshotter::Impl>>(
|
||||
"Map Snapshotter", std::move(scheduler), style, size, pixelRatio, cameraOptions,
|
||||
"Map Snapshotter", style, size, pixelRatio, cameraOptions,
|
||||
region, programCacheDir, localFontFamily, resourceOptions.clone())) {}
|
||||
|
||||
MapSnapshotter::~MapSnapshotter() = default;
|
||||
|
||||
@@ -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
|
||||
@@ -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/util/string.hpp>
|
||||
#include <mbgl/storage/default_file_source.hpp>
|
||||
#include <mbgl/style/style.hpp>
|
||||
@@ -109,10 +108,9 @@ int main(int argc, char *argv[]) {
|
||||
mbgl::Log::Warning(mbgl::Event::Setup, "Application is offline. Press `O` to toggle online status.");
|
||||
}
|
||||
|
||||
mbgl::ThreadPool threadPool(4);
|
||||
GLFWRendererFrontend rendererFrontend { std::make_unique<mbgl::Renderer>(view->getRendererBackend(), view->getPixelRatio(), threadPool), *view };
|
||||
GLFWRendererFrontend rendererFrontend { std::make_unique<mbgl::Renderer>(view->getRendererBackend(), view->getPixelRatio()), *view };
|
||||
|
||||
mbgl::Map map(rendererFrontend, *view, threadPool,
|
||||
mbgl::Map map(rendererFrontend, *view,
|
||||
mbgl::MapOptions().withSize(view->getSize()).withPixelRatio(view->getPixelRatio()), resourceOptions);
|
||||
|
||||
backend.setMap(&map);
|
||||
@@ -199,5 +197,6 @@ int main(int argc, char *argv[]) {
|
||||
settings.latitude, settings.longitude, settings.zoom, settings.bearing);
|
||||
|
||||
view = nullptr;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -14,9 +14,7 @@
|
||||
"platform/default/src/mbgl/gl/headless_frontend.cpp",
|
||||
"platform/default/src/mbgl/map/map_snapshotter.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 +24,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"
|
||||
|
||||
@@ -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/resource_options.hpp>
|
||||
#include <mbgl/storage/network_status.hpp>
|
||||
#include <mbgl/style/style.hpp>
|
||||
@@ -29,7 +28,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>
|
||||
|
||||
@@ -280,8 +278,6 @@ public:
|
||||
MBGLView *_mbglView;
|
||||
std::unique_ptr<MGLRenderFrontend> _rendererFrontend;
|
||||
|
||||
std::shared_ptr<mbgl::ThreadPool> _mbglThreadPool;
|
||||
|
||||
BOOL _opaque;
|
||||
|
||||
MGLAnnotationTagContextMap _annotationContextsByAnnotationTag;
|
||||
@@ -476,9 +472,8 @@ public:
|
||||
|
||||
// setup mbgl map
|
||||
MGLRendererConfiguration *config = [MGLRendererConfiguration currentConfiguration];
|
||||
_mbglThreadPool = mbgl::sharedThreadPool();
|
||||
|
||||
auto renderer = std::make_unique<mbgl::Renderer>(*_mbglView, config.scaleFactor, *_mbglThreadPool, config.cacheDir, config.localFontFamilyName);
|
||||
auto renderer = std::make_unique<mbgl::Renderer>(*_mbglView, config.scaleFactor, config.cacheDir, config.localFontFamilyName);
|
||||
BOOL enableCrossSourceCollisions = !config.perSourceCollisions;
|
||||
_rendererFrontend = std::make_unique<MGLRenderFrontend>(std::move(renderer), self, *_mbglView);
|
||||
|
||||
@@ -495,7 +490,7 @@ public:
|
||||
.withAssetPath([NSBundle mainBundle].resourceURL.path.UTF8String);
|
||||
|
||||
NSAssert(!_mbglMap, @"_mbglMap should be NULL");
|
||||
_mbglMap = new mbgl::Map(*_rendererFrontend, *_mbglView, *_mbglThreadPool, mapOptions, resourceOptions);
|
||||
_mbglMap = new mbgl::Map(*_rendererFrontend, *_mbglView, mapOptions, resourceOptions);
|
||||
|
||||
// start paused if in IB
|
||||
if (background) {
|
||||
@@ -772,7 +767,6 @@ public:
|
||||
_mbglView = nullptr;
|
||||
|
||||
_rendererFrontend.reset();
|
||||
_mbglThreadPool.reset();
|
||||
}
|
||||
|
||||
- (void)dealloc
|
||||
|
||||
@@ -72,11 +72,6 @@ macro(mbgl_platform_core)
|
||||
# Snapshotting
|
||||
PRIVATE platform/default/src/mbgl/map/map_snapshotter.cpp
|
||||
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
|
||||
)
|
||||
|
||||
target_include_directories(mbgl-core
|
||||
|
||||
@@ -13,9 +13,7 @@
|
||||
"platform/default/src/mbgl/gl/headless_frontend.cpp",
|
||||
"platform/default/src/mbgl/map/map_snapshotter.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 +22,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"
|
||||
|
||||
@@ -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/gl/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, *_mbglThreadPool, config.cacheDir, config.localFontFamilyName);
|
||||
auto renderer = std::make_unique<mbgl::Renderer>(*_mbglView, config.scaleFactor, config.cacheDir, config.localFontFamilyName);
|
||||
BOOL enableCrossSourceCollisions = !config.perSourceCollisions;
|
||||
_rendererFrontend = std::make_unique<MGLRenderFrontend>(std::move(renderer), self, *_mbglView, true);
|
||||
|
||||
@@ -302,7 +298,7 @@ public:
|
||||
resourceOptions.withCachePath([[MGLOfflineStorage sharedOfflineStorage] mbglCachePath])
|
||||
.withAssetPath([NSBundle mainBundle].resourceURL.path.UTF8String);
|
||||
|
||||
_mbglMap = new mbgl::Map(*_rendererFrontend, *_mbglView, *_mbglThreadPool, mapOptions, resourceOptions);
|
||||
_mbglMap = new mbgl::Map(*_rendererFrontend, *_mbglView, mapOptions, resourceOptions);
|
||||
|
||||
// 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.
|
||||
|
||||
@@ -630,8 +630,8 @@ void NodeMap::cancel() {
|
||||
reinterpret_cast<NodeMap *>(h->data)->renderFinished();
|
||||
});
|
||||
|
||||
frontend = std::make_unique<mbgl::HeadlessFrontend>(mbgl::Size{ 256, 256 }, pixelRatio, threadpool);
|
||||
map = std::make_unique<mbgl::Map>(*frontend, mapObserver, threadpool,
|
||||
frontend = std::make_unique<mbgl::HeadlessFrontend>(mbgl::Size{ 256, 256 }, pixelRatio);
|
||||
map = std::make_unique<mbgl::Map>(*frontend, mapObserver,
|
||||
mbgl::MapOptions().withSize(frontend->getSize())
|
||||
.withPixelRatio(pixelRatio)
|
||||
.withMapMode(mode)
|
||||
@@ -1214,8 +1214,8 @@ NodeMap::NodeMap(v8::Local<v8::Object> options)
|
||||
: true;
|
||||
}())
|
||||
, mapObserver(NodeMapObserver())
|
||||
, frontend(std::make_unique<mbgl::HeadlessFrontend>(mbgl::Size { 256, 256 }, pixelRatio, threadpool))
|
||||
, map(std::make_unique<mbgl::Map>(*frontend, mapObserver, threadpool,
|
||||
, frontend(std::make_unique<mbgl::HeadlessFrontend>(mbgl::Size { 256, 256 }, pixelRatio))
|
||||
, map(std::make_unique<mbgl::Map>(*frontend, mapObserver,
|
||||
mbgl::MapOptions().withSize(frontend->getSize())
|
||||
.withPixelRatio(pixelRatio)
|
||||
.withMapMode(mode)
|
||||
|
||||
@@ -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>
|
||||
@@ -79,7 +77,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;
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -17,12 +17,6 @@ set(MBGL_QT_CORE_FILES
|
||||
PRIVATE platform/default/include/mbgl/gl/headless_backend.hpp
|
||||
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
|
||||
|
||||
# Thread
|
||||
PRIVATE platform/qt/src/thread_local.cpp
|
||||
|
||||
|
||||
@@ -43,7 +43,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>
|
||||
|
||||
@@ -1724,7 +1723,6 @@ mbgl::ResourceOptions resourceOptionsFromQMapboxGLSettings(const QMapboxGLSettin
|
||||
|
||||
QMapboxGLPrivate::QMapboxGLPrivate(QMapboxGL *q, const QMapboxGLSettings &settings, const QSize &size, qreal pixelRatio_)
|
||||
: QObject(q)
|
||||
, m_threadPool(mbgl::sharedThreadPool())
|
||||
, m_mode(settings.contextMode())
|
||||
, m_pixelRatio(pixelRatio_)
|
||||
, m_localFontFamily(settings.localFontFamily())
|
||||
@@ -1741,7 +1739,7 @@ QMapboxGLPrivate::QMapboxGLPrivate(QMapboxGL *q, const QMapboxGLSettings &settin
|
||||
auto resourceOptions = resourceOptionsFromQMapboxGLSettings(settings);
|
||||
|
||||
// Setup the Map object.
|
||||
mapObj = std::make_unique<mbgl::Map>(*this, *m_mapObserver, *m_threadPool,
|
||||
mapObj = std::make_unique<mbgl::Map>(*this, *m_mapObserver,
|
||||
mapOptionsFromQMapboxGLSettings(settings, size, m_pixelRatio),
|
||||
resourceOptions);
|
||||
|
||||
@@ -1799,7 +1797,6 @@ void QMapboxGLPrivate::createRenderer()
|
||||
|
||||
m_mapRenderer = std::make_unique<QMapboxGLMapRenderer>(
|
||||
m_pixelRatio,
|
||||
*m_threadPool,
|
||||
m_mode,
|
||||
m_localFontFamily
|
||||
);
|
||||
|
||||
@@ -26,9 +26,9 @@ static auto *getScheduler() {
|
||||
return scheduler.localData().get();
|
||||
};
|
||||
|
||||
QMapboxGLMapRenderer::QMapboxGLMapRenderer(qreal pixelRatio, mbgl::ThreadPool &tp, QMapboxGLSettings::GLContextMode mode, const QString &localFontFamily)
|
||||
QMapboxGLMapRenderer::QMapboxGLMapRenderer(qreal pixelRatio, QMapboxGLSettings::GLContextMode mode, const QString &localFontFamily)
|
||||
: m_backend(static_cast<mbgl::gfx::ContextMode>(mode)),
|
||||
m_renderer(std::make_unique<mbgl::Renderer>(m_backend, pixelRatio, tp, mbgl::optional<std::string> {},
|
||||
m_renderer(std::make_unique<mbgl::Renderer>(m_backend, pixelRatio, mbgl::optional<std::string> {},
|
||||
localFontFamily.isEmpty() ? mbgl::nullopt : mbgl::optional<std::string> { localFontFamily.toStdString() }))
|
||||
, m_forceScheduler(needsToForceScheduler())
|
||||
{
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
|
||||
#include <mbgl/renderer/renderer.hpp>
|
||||
#include <mbgl/renderer/renderer_observer.hpp>
|
||||
#include <mbgl/util/shared_thread_pool.hpp>
|
||||
#include <mbgl/util/util.hpp>
|
||||
|
||||
#include <QtGlobal>
|
||||
@@ -25,7 +24,7 @@ class QMapboxGLMapRenderer : public QObject
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
QMapboxGLMapRenderer(qreal pixelRatio, mbgl::ThreadPool &, QMapboxGLSettings::GLContextMode, const QString &localFontFamily);
|
||||
QMapboxGLMapRenderer(qreal pixelRatio, QMapboxGLSettings::GLContextMode, const QString &localFontFamily);
|
||||
virtual ~QMapboxGLMapRenderer();
|
||||
|
||||
void render();
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
#include <mbgl/map/map.hpp>
|
||||
#include <mbgl/renderer/renderer_frontend.hpp>
|
||||
#include <mbgl/storage/resource_transform.hpp>
|
||||
#include <mbgl/util/default_thread_pool.hpp>
|
||||
#include <mbgl/util/geo.hpp>
|
||||
|
||||
#include <QObject>
|
||||
@@ -56,7 +55,6 @@ private:
|
||||
std::shared_ptr<mbgl::UpdateParameters> m_updateParameters;
|
||||
|
||||
std::unique_ptr<QMapboxGLMapObserver> m_mapObserver;
|
||||
std::shared_ptr<mbgl::ThreadPool> m_threadPool;
|
||||
std::unique_ptr<QMapboxGLMapRenderer> m_mapRenderer;
|
||||
std::unique_ptr<mbgl::Actor<mbgl::ResourceTransform>> m_resourceTransform;
|
||||
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
|
||||
#include <mbgl/gfx/renderable.hpp>
|
||||
#include <mbgl/gl/renderer_backend.hpp>
|
||||
#include <mbgl/util/shared_thread_pool.hpp>
|
||||
|
||||
class QMapboxGLRendererBackend final : public mbgl::gl::RendererBackend,
|
||||
public mbgl::gfx::Renderable {
|
||||
|
||||
@@ -302,6 +302,7 @@
|
||||
"src/mbgl/util/rapidjson.cpp",
|
||||
"src/mbgl/util/stopwatch.cpp",
|
||||
"src/mbgl/util/string.cpp",
|
||||
"src/mbgl/util/thread_pool.cpp",
|
||||
"src/mbgl/util/tile_cover.cpp",
|
||||
"src/mbgl/util/tile_cover_impl.cpp",
|
||||
"src/mbgl/util/tiny_sdf.cpp",
|
||||
@@ -762,6 +763,7 @@
|
||||
"mbgl/util/std.hpp": "src/mbgl/util/std.hpp",
|
||||
"mbgl/util/stopwatch.hpp": "src/mbgl/util/stopwatch.hpp",
|
||||
"mbgl/util/thread_local.hpp": "src/mbgl/util/thread_local.hpp",
|
||||
"mbgl/util/thread_pool.hpp": "src/mbgl/util/thread_pool.hpp",
|
||||
"mbgl/util/tile_coordinate.hpp": "src/mbgl/util/tile_coordinate.hpp",
|
||||
"mbgl/util/tile_cover.hpp": "src/mbgl/util/tile_cover.hpp",
|
||||
"mbgl/util/tile_cover_impl.hpp": "src/mbgl/util/tile_cover_impl.hpp",
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
#include <mbgl/actor/scheduler.hpp>
|
||||
#include <mbgl/util/thread_local.hpp>
|
||||
#include <mbgl/util/thread_pool.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
|
||||
util::ThreadLocal<Scheduler> g_currentScheduler;
|
||||
|
||||
static auto& current() {
|
||||
static util::ThreadLocal<Scheduler> scheduler;
|
||||
return scheduler;
|
||||
@@ -16,4 +19,19 @@ Scheduler* Scheduler::GetCurrent() {
|
||||
return current().get();
|
||||
}
|
||||
|
||||
// static
|
||||
std::shared_ptr<Scheduler> Scheduler::GetBackground() {
|
||||
static std::weak_ptr<Scheduler> weak;
|
||||
static std::mutex mtx;
|
||||
|
||||
std::lock_guard<std::mutex> lock(mtx);
|
||||
std::shared_ptr<Scheduler> scheduler = weak.lock();
|
||||
|
||||
if (!scheduler) {
|
||||
weak = scheduler = std::make_shared<ThreadPool>(4);
|
||||
}
|
||||
|
||||
return scheduler;
|
||||
}
|
||||
|
||||
} //namespace mbgl
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -29,10 +28,9 @@ using namespace style;
|
||||
|
||||
Map::Map(RendererFrontend& frontend,
|
||||
MapObserver& observer,
|
||||
Scheduler& scheduler,
|
||||
const MapOptions& mapOptions,
|
||||
const ResourceOptions& resourceOptions)
|
||||
: impl(std::make_unique<Impl>(frontend, observer, scheduler,
|
||||
: impl(std::make_unique<Impl>(frontend, observer,
|
||||
FileSource::getSharedFileSource(resourceOptions),
|
||||
mapOptions)) {}
|
||||
|
||||
|
||||
@@ -9,18 +9,16 @@ namespace mbgl {
|
||||
|
||||
Map::Impl::Impl(RendererFrontend& frontend_,
|
||||
MapObserver& observer_,
|
||||
Scheduler& scheduler_,
|
||||
std::shared_ptr<FileSource> fileSource_,
|
||||
const MapOptions& mapOptions)
|
||||
: observer(observer_),
|
||||
rendererFrontend(frontend_),
|
||||
scheduler(scheduler_),
|
||||
transform(observer, mapOptions.constrainMode(), mapOptions.viewportMode()),
|
||||
mode(mapOptions.mapMode()),
|
||||
pixelRatio(mapOptions.pixelRatio()),
|
||||
crossSourceCollisions(mapOptions.crossSourceCollisions()),
|
||||
fileSource(std::move(fileSource_)),
|
||||
style(std::make_unique<style::Style>(scheduler, *fileSource, pixelRatio)),
|
||||
style(std::make_unique<style::Style>(*fileSource, pixelRatio)),
|
||||
annotationManager(*style) {
|
||||
transform.setNorthOrientation(mapOptions.northOrientation());
|
||||
style->impl->setObserver(this);
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#include <mbgl/actor/actor.hpp>
|
||||
#include <mbgl/actor/scheduler.hpp>
|
||||
#include <mbgl/annotation/annotation_manager.hpp>
|
||||
#include <mbgl/map/map.hpp>
|
||||
#include <mbgl/map/map_observer.hpp>
|
||||
@@ -30,7 +28,7 @@ struct StillImageRequest {
|
||||
|
||||
class Map::Impl : public style::Observer, public RendererObserver {
|
||||
public:
|
||||
Impl(RendererFrontend&, MapObserver&, Scheduler&, std::shared_ptr<FileSource>, const MapOptions&);
|
||||
Impl(RendererFrontend&, MapObserver&, std::shared_ptr<FileSource>, const MapOptions&);
|
||||
~Impl() final;
|
||||
|
||||
// StyleObserver
|
||||
@@ -54,7 +52,6 @@ public:
|
||||
|
||||
MapObserver& observer;
|
||||
RendererFrontend& rendererFrontend;
|
||||
Scheduler& scheduler;
|
||||
|
||||
Transform transform;
|
||||
|
||||
|
||||
@@ -9,12 +9,10 @@ namespace mbgl {
|
||||
|
||||
Renderer::Renderer(gfx::RendererBackend& backend,
|
||||
float pixelRatio_,
|
||||
Scheduler& scheduler_,
|
||||
const optional<std::string> programCacheDir_,
|
||||
const optional<std::string> localFontFamily_)
|
||||
: impl(std::make_unique<Impl>(backend,
|
||||
pixelRatio_,
|
||||
scheduler_,
|
||||
std::move(programCacheDir_),
|
||||
std::move(localFontFamily_))) {
|
||||
}
|
||||
|
||||
@@ -40,11 +40,9 @@ static RendererObserver& nullObserver() {
|
||||
|
||||
Renderer::Impl::Impl(gfx::RendererBackend& backend_,
|
||||
float pixelRatio_,
|
||||
Scheduler& scheduler_,
|
||||
const optional<std::string> programCacheDir_,
|
||||
const optional<std::string> localFontFamily_)
|
||||
: backend(backend_)
|
||||
, scheduler(scheduler_)
|
||||
, observer(&nullObserver())
|
||||
, pixelRatio(pixelRatio_)
|
||||
, programCacheDir(std::move(programCacheDir_))
|
||||
@@ -114,7 +112,6 @@ void Renderer::Impl::render(const UpdateParameters& updateParameters) {
|
||||
updateParameters.pixelRatio,
|
||||
updateParameters.debugOptions,
|
||||
updateParameters.transformState,
|
||||
scheduler,
|
||||
updateParameters.fileSource,
|
||||
updateParameters.mode,
|
||||
updateParameters.annotationManager,
|
||||
|
||||
@@ -26,7 +26,6 @@ class UpdateParameters;
|
||||
class RenderStaticData;
|
||||
class RenderedQueryOptions;
|
||||
class SourceQueryOptions;
|
||||
class Scheduler;
|
||||
class GlyphManager;
|
||||
class ImageManager;
|
||||
class LineAtlas;
|
||||
@@ -42,7 +41,6 @@ class Renderer::Impl : public GlyphManagerObserver,
|
||||
public:
|
||||
Impl(gfx::RendererBackend&,
|
||||
float pixelRatio_,
|
||||
Scheduler&,
|
||||
const optional<std::string> programCacheDir,
|
||||
const optional<std::string> localFontFamily_);
|
||||
~Impl() final;
|
||||
@@ -99,7 +97,6 @@ private:
|
||||
friend class Renderer;
|
||||
|
||||
gfx::RendererBackend& backend;
|
||||
Scheduler& scheduler;
|
||||
|
||||
RendererObserver* observer;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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*);
|
||||
|
||||
|
||||
@@ -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,8 +13,7 @@ namespace style {
|
||||
CustomGeometrySource::CustomGeometrySource(std::string id,
|
||||
const CustomGeometrySource::Options options)
|
||||
: Source(makeMutable<CustomGeometrySource::Impl>(std::move(id), options)),
|
||||
threadPool(sharedThreadPool()),
|
||||
loader(std::make_unique<Actor<CustomTileLoader>>(*threadPool, options.fetchTileFunction, options.cancelTileFunction)) {
|
||||
loader(std::make_unique<Actor<CustomTileLoader>>(Scheduler::GetBackground(), options.fetchTileFunction, options.cancelTileFunction)) {
|
||||
}
|
||||
|
||||
CustomGeometrySource::~CustomGeometrySource() = default;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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_,
|
||||
ImageRequestor(parameters.imageManager),
|
||||
sourceID(std::move(sourceID_)),
|
||||
mailbox(std::make_shared<Mailbox>(*Scheduler::GetCurrent())),
|
||||
worker(parameters.workerScheduler,
|
||||
worker(Scheduler::GetBackground(),
|
||||
ActorRef<GeometryTile>(*this, mailbox),
|
||||
id_,
|
||||
sourceID,
|
||||
|
||||
@@ -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>
|
||||
@@ -17,7 +18,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;
|
||||
|
||||
@@ -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>
|
||||
@@ -17,7 +18,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)) {
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include <mbgl/util/default_thread_pool.hpp>
|
||||
#include <mbgl/actor/mailbox.hpp>
|
||||
#include <mbgl/util/thread_pool.hpp>
|
||||
|
||||
#include <mbgl/util/platform.hpp>
|
||||
#include <mbgl/util/string.hpp>
|
||||
|
||||
@@ -7,6 +7,7 @@ namespace mbgl {
|
||||
|
||||
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));
|
||||
@@ -1,5 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <mbgl/actor/mailbox.hpp>
|
||||
#include <mbgl/actor/scheduler.hpp>
|
||||
|
||||
#include <condition_variable>
|
||||
@@ -9,9 +10,9 @@
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
class ThreadPool : public Scheduler {
|
||||
class ThreadPool final : public Scheduler {
|
||||
public:
|
||||
ThreadPool(std::size_t count);
|
||||
explicit ThreadPool(std::size_t count);
|
||||
~ThreadPool() override;
|
||||
|
||||
void schedule(std::weak_ptr<Mailbox>) override;
|
||||
@@ -21,7 +22,7 @@ private:
|
||||
std::queue<std::weak_ptr<Mailbox>> queue;
|
||||
std::mutex mutex;
|
||||
std::condition_variable cv;
|
||||
bool terminate { false };
|
||||
bool terminate{ false };
|
||||
};
|
||||
|
||||
} // namespace mbgl
|
||||
@@ -1,8 +1,8 @@
|
||||
#include <mbgl/actor/actor.hpp>
|
||||
#include <mbgl/util/default_thread_pool.hpp>
|
||||
#include <mbgl/util/run_loop.hpp>
|
||||
|
||||
#include <mbgl/actor/scheduler.hpp>
|
||||
#include <mbgl/test/util.hpp>
|
||||
#include <mbgl/util/run_loop.hpp>
|
||||
|
||||
#include <chrono>
|
||||
#include <functional>
|
||||
@@ -20,9 +20,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);
|
||||
}
|
||||
@@ -33,14 +32,13 @@ TEST(Actor, Destruction) {
|
||||
~Test() {
|
||||
destructed = true;
|
||||
}
|
||||
|
||||
|
||||
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 +70,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 +153,9 @@ TEST(Actor, DestructionAllowedInReceiveOnSameThread) {
|
||||
}
|
||||
};
|
||||
|
||||
ThreadPool pool { 1 };
|
||||
|
||||
std::promise<void> callbackFiredPromise;
|
||||
|
||||
auto test = std::make_unique<Actor<Test>>(pool);
|
||||
auto retainer = Scheduler::GetBackground();
|
||||
auto test = std::make_unique<Actor<Test>>(retainer);
|
||||
|
||||
// Callback (triggered while mutex is locked in Mailbox::receive())
|
||||
test->self().invoke(&Test::callMeBack, [&]() {
|
||||
@@ -189,12 +183,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 +243,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 +277,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,13 +301,12 @@ TEST(Actor, Ask) {
|
||||
}
|
||||
};
|
||||
|
||||
ThreadPool pool { 2 };
|
||||
Actor<Test> test(pool);
|
||||
Actor<Test> test(Scheduler::GetBackground());
|
||||
|
||||
auto result = test.self().ask(&Test::doubleIt, 1);
|
||||
|
||||
ASSERT_TRUE(result.valid());
|
||||
|
||||
|
||||
auto status = result.wait_for(std::chrono::seconds(1));
|
||||
ASSERT_EQ(std::future_status::ready, status);
|
||||
ASSERT_EQ(2, result.get());
|
||||
@@ -339,9 +326,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);
|
||||
@@ -349,31 +335,30 @@ TEST(Actor, AskVoid) {
|
||||
|
||||
TEST(Actor, NoSelfActorRef) {
|
||||
// Not all actors need a reference to self
|
||||
|
||||
|
||||
// Trivially constructable
|
||||
struct Trivial {};
|
||||
|
||||
ThreadPool pool { 2 };
|
||||
Actor<Trivial> trivial(pool);
|
||||
|
||||
|
||||
|
||||
Actor<Trivial> trivial(Scheduler::GetBackground());
|
||||
|
||||
|
||||
// With arguments
|
||||
struct WithArguments {
|
||||
std::promise<void> promise;
|
||||
|
||||
|
||||
WithArguments(std::promise<void> promise_)
|
||||
: promise(std::move(promise_)) {
|
||||
}
|
||||
|
||||
|
||||
void receive() {
|
||||
promise.set_value();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
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();
|
||||
}
|
||||
@@ -386,32 +371,32 @@ TEST(Actor, TwoPhaseConstruction) {
|
||||
struct Test {
|
||||
Test(ActorRef<Test>, std::shared_ptr<bool> destroyed_)
|
||||
: destroyed(std::move(destroyed_)) {};
|
||||
|
||||
|
||||
~Test() {
|
||||
*destroyed = true;
|
||||
}
|
||||
|
||||
|
||||
void callMe(std::promise<void> p) {
|
||||
p.set_value();
|
||||
}
|
||||
|
||||
|
||||
void stop() {
|
||||
util::RunLoop::Get()->stop();
|
||||
}
|
||||
|
||||
|
||||
std::shared_ptr<bool> destroyed;
|
||||
};
|
||||
|
||||
AspiringActor<Test> parent;
|
||||
|
||||
|
||||
auto destroyed = std::make_shared<bool>(false);
|
||||
|
||||
|
||||
std::promise<void> queueExecuted;
|
||||
auto queueExecutedFuture = queueExecuted.get_future();
|
||||
|
||||
|
||||
parent.self().invoke(&Test::callMe, std::move(queueExecuted));
|
||||
parent.self().invoke(&Test::stop);
|
||||
|
||||
|
||||
auto thread = std::thread([
|
||||
capturedArgs = std::make_tuple(destroyed),
|
||||
&parent
|
||||
@@ -420,11 +405,11 @@ TEST(Actor, TwoPhaseConstruction) {
|
||||
EstablishedActor<Test> test(loop, parent, capturedArgs);
|
||||
loop.run();
|
||||
});
|
||||
|
||||
|
||||
// should not hang
|
||||
queueExecutedFuture.get();
|
||||
thread.join();
|
||||
|
||||
|
||||
EXPECT_TRUE(*destroyed);
|
||||
}
|
||||
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
#include <mbgl/test/stub_file_source.hpp>
|
||||
#include <mbgl/test/map_adapter.hpp>
|
||||
|
||||
#include <mbgl/util/default_thread_pool.hpp>
|
||||
#include <mbgl/annotation/annotation.hpp>
|
||||
#include <mbgl/style/style.hpp>
|
||||
#include <mbgl/style/image.hpp>
|
||||
@@ -28,10 +27,9 @@ std::unique_ptr<style::Image> namedMarker(const std::string& name) {
|
||||
class AnnotationTest {
|
||||
public:
|
||||
util::RunLoop loop;
|
||||
ThreadPool threadPool { 4 };
|
||||
HeadlessFrontend frontend { 1, threadPool };
|
||||
HeadlessFrontend frontend { 1 };
|
||||
|
||||
MapAdapter map { frontend, MapObserver::nullObserver(), std::make_shared<StubFileSource>(), threadPool,
|
||||
MapAdapter map { frontend, MapObserver::nullObserver(), std::make_shared<StubFileSource>(),
|
||||
MapOptions().withMapMode(MapMode::Static).withSize(frontend.getSize())};
|
||||
|
||||
void checkRendering(const char * name) {
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
#include <mbgl/map/map_options.hpp>
|
||||
#include <mbgl/gfx/backend_scope.hpp>
|
||||
#include <mbgl/gl/headless_frontend.hpp>
|
||||
#include <mbgl/util/default_thread_pool.hpp>
|
||||
#include <mbgl/util/exception.hpp>
|
||||
#include <mbgl/util/run_loop.hpp>
|
||||
|
||||
@@ -21,11 +20,10 @@ TEST(API, RenderWithoutCallback) {
|
||||
|
||||
util::RunLoop loop;
|
||||
|
||||
ThreadPool threadPool(4);
|
||||
HeadlessFrontend frontend { 1, threadPool };
|
||||
HeadlessFrontend frontend { 1 };
|
||||
|
||||
auto map = std::make_unique<MapAdapter>(frontend, MapObserver::nullObserver(),
|
||||
std::make_shared<StubFileSource>(), threadPool,
|
||||
std::make_shared<StubFileSource>(),
|
||||
MapOptions().withMapMode(MapMode::Static).withSize(frontend.getSize()));
|
||||
map->renderStill(nullptr);
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
#include <mbgl/map/map.hpp>
|
||||
#include <mbgl/map/map_options.hpp>
|
||||
#include <mbgl/util/shared_thread_pool.hpp>
|
||||
#include <mbgl/gl/headless_frontend.hpp>
|
||||
#include <mbgl/storage/resource_options.hpp>
|
||||
#include <mbgl/style/style.hpp>
|
||||
@@ -20,9 +19,8 @@ using namespace mbgl::style;
|
||||
TEST(CustomGeometrySource, Grid) {
|
||||
util::RunLoop loop;
|
||||
|
||||
auto threadPool = sharedThreadPool();
|
||||
HeadlessFrontend frontend { 1, *threadPool };
|
||||
Map map(frontend, MapObserver::nullObserver(), *threadPool,
|
||||
HeadlessFrontend frontend { 1 };
|
||||
Map map(frontend, MapObserver::nullObserver(),
|
||||
MapOptions().withMapMode(MapMode::Static).withSize(frontend.getSize()),
|
||||
ResourceOptions().withCachePath(":memory:").withAssetPath("test/fixtures/api/assets"));
|
||||
map.getStyle().loadJSON(util::read_file("test/fixtures/api/water.json"));
|
||||
|
||||
@@ -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/gl/defines.hpp>
|
||||
#include <mbgl/gl/headless_frontend.hpp>
|
||||
#include <mbgl/storage/resource_options.hpp>
|
||||
@@ -90,9 +89,8 @@ public:
|
||||
TEST(CustomLayer, Basic) {
|
||||
util::RunLoop loop;
|
||||
|
||||
ThreadPool threadPool(4);
|
||||
HeadlessFrontend frontend { 1, threadPool };
|
||||
Map map(frontend, MapObserver::nullObserver(), threadPool,
|
||||
HeadlessFrontend frontend { 1 };
|
||||
Map map(frontend, MapObserver::nullObserver(),
|
||||
MapOptions().withMapMode(MapMode::Static).withSize(frontend.getSize()),
|
||||
ResourceOptions().withCachePath(":memory:").withAssetPath("test/fixtures/api/assets"));
|
||||
map.getStyle().loadJSON(util::read_file("test/fixtures/api/water.json"));
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
#include <mbgl/test/map_adapter.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>
|
||||
@@ -35,9 +34,8 @@ public:
|
||||
|
||||
util::RunLoop loop;
|
||||
std::shared_ptr<StubFileSource> fileSource = std::make_shared<StubFileSource>();
|
||||
ThreadPool threadPool { 4 };
|
||||
HeadlessFrontend frontend { 1, threadPool };
|
||||
MapAdapter map { frontend, MapObserver::nullObserver(), fileSource, threadPool,
|
||||
HeadlessFrontend frontend { 1 };
|
||||
MapAdapter map { frontend, MapObserver::nullObserver(), fileSource,
|
||||
MapOptions().withMapMode(MapMode::Static).withSize(frontend.getSize())};
|
||||
};
|
||||
|
||||
|
||||
@@ -9,7 +9,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>
|
||||
@@ -23,11 +22,9 @@ using namespace mbgl::style;
|
||||
TEST(API, RecycleMapUpdateImages) {
|
||||
util::RunLoop loop;
|
||||
|
||||
ThreadPool threadPool(4);
|
||||
|
||||
HeadlessFrontend frontend { 1, threadPool };
|
||||
HeadlessFrontend frontend { 1 };
|
||||
auto map = std::make_unique<MapAdapter>(frontend, MapObserver::nullObserver(),
|
||||
std::make_shared<StubFileSource>(), threadPool,
|
||||
std::make_shared<StubFileSource>(),
|
||||
MapOptions().withMapMode(MapMode::Static).withSize(frontend.getSize()));
|
||||
|
||||
EXPECT_TRUE(map);
|
||||
|
||||
@@ -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/gfx/backend_scope.hpp>
|
||||
#include <mbgl/gl/defines.hpp>
|
||||
#include <mbgl/gl/headless_frontend.hpp>
|
||||
@@ -88,11 +87,9 @@ struct Buffer {
|
||||
TEST(GLContextMode, Shared) {
|
||||
util::RunLoop loop;
|
||||
|
||||
ThreadPool threadPool(4);
|
||||
HeadlessFrontend frontend { 1, {}, gfx::ContextMode::Shared };
|
||||
|
||||
HeadlessFrontend frontend { 1, threadPool, {}, gfx::ContextMode::Shared };
|
||||
|
||||
Map map(frontend, MapObserver::nullObserver(), threadPool,
|
||||
Map map(frontend, MapObserver::nullObserver(),
|
||||
MapOptions().withMapMode(MapMode::Static).withSize(frontend.getSize()),
|
||||
ResourceOptions().withCachePath(":memory:").withAssetPath("test/fixtures/api/assets"));
|
||||
map.getStyle().loadJSON(util::read_file("test/fixtures/api/water.json"));
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
#include <mbgl/gfx/backend_scope.hpp>
|
||||
#include <mbgl/gl/context.hpp>
|
||||
#include <mbgl/gl/headless_frontend.hpp>
|
||||
#include <mbgl/util/default_thread_pool.hpp>
|
||||
#include <mbgl/storage/resource_options.hpp>
|
||||
#include <mbgl/storage/network_status.hpp>
|
||||
#include <mbgl/storage/default_file_source.hpp>
|
||||
@@ -34,15 +33,14 @@ class MapTest {
|
||||
public:
|
||||
util::RunLoop runLoop;
|
||||
std::shared_ptr<FileSource> fileSource;
|
||||
ThreadPool threadPool { 4 };
|
||||
StubMapObserver observer;
|
||||
HeadlessFrontend frontend;
|
||||
MapAdapter map;
|
||||
|
||||
MapTest(float pixelRatio = 1, MapMode mode = MapMode::Static)
|
||||
: fileSource(std::make_shared<FileSource>())
|
||||
, frontend(pixelRatio, threadPool)
|
||||
, map(frontend, observer, fileSource, threadPool,
|
||||
, frontend(pixelRatio)
|
||||
, map(frontend, observer, fileSource,
|
||||
MapOptions().withMapMode(mode).withSize(frontend.getSize()).withPixelRatio(pixelRatio)) {}
|
||||
|
||||
template <typename T = FileSource>
|
||||
@@ -50,8 +48,8 @@ public:
|
||||
float pixelRatio = 1, MapMode mode = MapMode::Static,
|
||||
typename std::enable_if<std::is_same<T, DefaultFileSource>::value>::type* = nullptr)
|
||||
: fileSource(std::make_shared<T>(cachePath, assetPath))
|
||||
, frontend(pixelRatio, threadPool)
|
||||
, map(frontend, observer, fileSource, threadPool,
|
||||
, frontend(pixelRatio)
|
||||
, map(frontend, observer, fileSource,
|
||||
MapOptions().withMapMode(mode).withSize(frontend.getSize()).withPixelRatio(pixelRatio)) {}
|
||||
};
|
||||
|
||||
@@ -744,7 +742,6 @@ TEST(Map, DontLoadUnneededTiles) {
|
||||
|
||||
TEST(Map, TEST_DISABLED_ON_CI(ContinuousRendering)) {
|
||||
util::RunLoop runLoop;
|
||||
ThreadPool threadPool { 4 };
|
||||
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
@@ -756,7 +753,7 @@ TEST(Map, TEST_DISABLED_ON_CI(ContinuousRendering)) {
|
||||
|
||||
util::Timer timer;
|
||||
|
||||
HeadlessFrontend frontend(1, threadPool);
|
||||
HeadlessFrontend frontend(1);
|
||||
|
||||
StubMapObserver observer;
|
||||
observer.didFinishRenderingFrameCallback = [&] (MapObserver::RenderMode) {
|
||||
@@ -768,7 +765,7 @@ TEST(Map, TEST_DISABLED_ON_CI(ContinuousRendering)) {
|
||||
});
|
||||
};
|
||||
|
||||
Map map(frontend, observer, threadPool,
|
||||
Map map(frontend, observer,
|
||||
MapOptions().withMapMode(MapMode::Continuous).withSize(frontend.getSize()),
|
||||
ResourceOptions().withCachePath(":memory:").withAssetPath("test/fixtures/api/assets"));
|
||||
map.getStyle().loadJSON(util::read_file("test/fixtures/api/water.json"));
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
#include <mbgl/map/map_options.hpp>
|
||||
#include <mbgl/gl/headless_frontend.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>
|
||||
@@ -22,7 +21,6 @@ using namespace std::chrono_literals;
|
||||
|
||||
TEST(Map, PrefetchTiles) {
|
||||
util::RunLoop runLoop;
|
||||
ThreadPool threadPool(4);
|
||||
std::shared_ptr<StubFileSource> fileSource = std::make_shared<StubFileSource>();
|
||||
|
||||
util::Timer emergencyShutoff;
|
||||
@@ -36,8 +34,8 @@ TEST(Map, PrefetchTiles) {
|
||||
runLoop.stop();
|
||||
};
|
||||
|
||||
HeadlessFrontend frontend { { 512, 512 }, 1, threadPool };
|
||||
MapAdapter map(frontend, observer, fileSource, threadPool,
|
||||
HeadlessFrontend frontend { { 512, 512 }, 1 };
|
||||
MapAdapter map(frontend, observer, fileSource,
|
||||
MapOptions().withMapMode(MapMode::Continuous).withSize(frontend.getSize()));
|
||||
|
||||
std::vector<int> tiles;
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -13,9 +13,8 @@ public:
|
||||
explicit MapAdapter(RendererFrontend& frontend,
|
||||
MapObserver& observer,
|
||||
std::shared_ptr<FileSource> fileSource,
|
||||
Scheduler& scheduler,
|
||||
const MapOptions& options)
|
||||
: Map(std::make_unique<Map::Impl>(frontend, observer, scheduler, std::move(fileSource), options)) {}
|
||||
: Map(std::make_unique<Map::Impl>(frontend, observer, std::move(fileSource), options)) {}
|
||||
};
|
||||
|
||||
} // namespace mbgl
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#include <mbgl/actor/scheduler.hpp>
|
||||
#include <mbgl/test.hpp>
|
||||
#include <mbgl/test/util.hpp>
|
||||
|
||||
|
||||
@@ -31,7 +31,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>
|
||||
@@ -55,8 +54,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 };
|
||||
@@ -65,7 +63,6 @@ public:
|
||||
1.0,
|
||||
MapDebugOptions(),
|
||||
transformState,
|
||||
threadPool,
|
||||
fileSource,
|
||||
MapMode::Continuous,
|
||||
annotationManager,
|
||||
@@ -763,7 +760,6 @@ TEST(Source, ImageSourceImageUpdate) {
|
||||
|
||||
TEST(Source, CustomGeometrySourceSetTileData) {
|
||||
SourceTest test;
|
||||
std::shared_ptr<ThreadPool> threadPool = sharedThreadPool();
|
||||
CustomGeometrySource source("source", CustomGeometrySource::Options());
|
||||
source.loadDescription(test.fileSource);
|
||||
|
||||
|
||||
@@ -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"));
|
||||
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
#include <mbgl/test/stub_file_source.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>
|
||||
@@ -283,9 +282,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
|
||||
|
||||
@@ -8,7 +8,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>
|
||||
|
||||
/*
|
||||
@@ -34,15 +33,14 @@ namespace {
|
||||
class LocalGlyphRasterizerTest {
|
||||
public:
|
||||
LocalGlyphRasterizerTest(const optional<std::string> fontFamily)
|
||||
: frontend(1, threadPool, optional<std::string>(), gfx::ContextMode::Unique, fontFamily)
|
||||
: frontend(1, optional<std::string>(), gfx::ContextMode::Unique, fontFamily)
|
||||
{
|
||||
}
|
||||
|
||||
util::RunLoop loop;
|
||||
std::shared_ptr<StubFileSource> fileSource = std::make_shared<StubFileSource>();
|
||||
ThreadPool threadPool { 4 };
|
||||
HeadlessFrontend frontend;
|
||||
MapAdapter map { frontend, MapObserver::nullObserver(), fileSource, threadPool,
|
||||
MapAdapter map { frontend, MapObserver::nullObserver(), fileSource,
|
||||
MapOptions().withMapMode(MapMode::Static).withSize(frontend.getSize())};
|
||||
|
||||
void checkRendering(const char * name) {
|
||||
|
||||
@@ -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>
|
||||
@@ -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 };
|
||||
@@ -36,7 +34,6 @@ public:
|
||||
1.0,
|
||||
MapDebugOptions(),
|
||||
transformState,
|
||||
threadPool,
|
||||
fileSource,
|
||||
MapMode::Continuous,
|
||||
annotationManager,
|
||||
|
||||
@@ -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>
|
||||
@@ -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 };
|
||||
@@ -36,7 +34,6 @@ public:
|
||||
1.0,
|
||||
MapDebugOptions(),
|
||||
transformState,
|
||||
threadPool,
|
||||
fileSource,
|
||||
MapMode::Continuous,
|
||||
annotationManager,
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -1,14 +1,15 @@
|
||||
#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/actor/scheduler.hpp>
|
||||
#include <mbgl/test/util.hpp>
|
||||
#include <mbgl/util/run_loop.hpp>
|
||||
|
||||
#include <atomic>
|
||||
#include <future>
|
||||
#include <vector>
|
||||
|
||||
using namespace mbgl;
|
||||
using namespace mbgl::util;
|
||||
|
||||
namespace {
|
||||
@@ -104,11 +105,11 @@ 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 retainer = Scheduler::GetBackground();
|
||||
auto mailbox = std::make_shared<Mailbox>(*retainer);
|
||||
|
||||
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 +134,11 @@ TEST(AsyncTask, ThreadSafety) {
|
||||
|
||||
AsyncTask async([&count] { ++count; });
|
||||
|
||||
mbgl::ThreadPool threads(numThreads);
|
||||
auto mailbox = std::make_shared<mbgl::Mailbox>(threads);
|
||||
auto retainer = Scheduler::GetBackground();
|
||||
auto mailbox = std::make_shared<Mailbox>(*retainer);
|
||||
|
||||
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.
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
|
||||
#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>
|
||||
@@ -37,7 +36,6 @@ public:
|
||||
|
||||
util::RunLoop runLoop;
|
||||
std::shared_ptr<StubFileSource> fileSource = std::make_shared<StubFileSource>();
|
||||
ThreadPool threadPool { 4 };
|
||||
|
||||
private:
|
||||
Response response(const std::string& path) {
|
||||
@@ -72,8 +70,8 @@ TEST(Memory, Vector) {
|
||||
MemoryTest test;
|
||||
float ratio { 2 };
|
||||
|
||||
HeadlessFrontend frontend { { 256, 256 }, ratio, test.threadPool };
|
||||
MapAdapter map(frontend, MapObserver::nullObserver(), test.fileSource, test.threadPool,
|
||||
HeadlessFrontend frontend { { 256, 256 }, ratio };
|
||||
MapAdapter map(frontend, MapObserver::nullObserver(), test.fileSource,
|
||||
MapOptions().withMapMode(MapMode::Static).withSize(frontend.getSize()).withPixelRatio(ratio));
|
||||
map.jumpTo(CameraOptions().withZoom(16));
|
||||
map.getStyle().loadURL("mapbox://streets");
|
||||
@@ -85,8 +83,8 @@ TEST(Memory, Raster) {
|
||||
MemoryTest test;
|
||||
float ratio { 2 };
|
||||
|
||||
HeadlessFrontend frontend { { 256, 256 }, ratio, test.threadPool };
|
||||
MapAdapter map(frontend, MapObserver::nullObserver(), test.fileSource, test.threadPool,
|
||||
HeadlessFrontend frontend { { 256, 256 }, ratio };
|
||||
MapAdapter map(frontend, MapObserver::nullObserver(), test.fileSource,
|
||||
MapOptions().withMapMode(MapMode::Static).withSize(frontend.getSize()).withPixelRatio(ratio));
|
||||
map.getStyle().loadURL("mapbox://satellite");
|
||||
|
||||
@@ -123,8 +121,8 @@ TEST(Memory, Footprint) {
|
||||
class FrontendAndMap {
|
||||
public:
|
||||
FrontendAndMap(MemoryTest& test_, const char* style)
|
||||
: frontend(Size{ 256, 256 }, 2, test_.threadPool)
|
||||
, map(frontend, MapObserver::nullObserver(), test_.fileSource, test_.threadPool,
|
||||
: frontend(Size{ 256, 256 }, 2)
|
||||
, map(frontend, MapObserver::nullObserver(), test_.fileSource,
|
||||
MapOptions().withMapMode(MapMode::Static).withSize(frontend.getSize()).withPixelRatio(2)) {
|
||||
map.jumpTo(CameraOptions().withZoom(16));
|
||||
map.getStyle().loadURL(style);
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
#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/actor/actor_ref.hpp>
|
||||
#include <mbgl/actor/scheduler.hpp>
|
||||
#include <mbgl/test/util.hpp>
|
||||
#include <mbgl/util/run_loop.hpp>
|
||||
#include <mbgl/util/timer.hpp>
|
||||
|
||||
#include <atomic>
|
||||
@@ -139,8 +140,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 +165,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");
|
||||
|
||||
Reference in New Issue
Block a user