Add TaggedScheduler, couple lifetime of tasks and orchestrator (#2398)
This commit is contained in:
@@ -54,17 +54,18 @@ using SourceType = mbgl::style::SourceType;
|
||||
|
||||
class SourceTest {
|
||||
public:
|
||||
util::SimpleIdentity uniqueID;
|
||||
util::RunLoop loop;
|
||||
std::shared_ptr<StubFileSource> fileSource = std::make_shared<StubFileSource>();
|
||||
StubStyleObserver styleObserver;
|
||||
StubRenderSourceObserver renderSourceObserver;
|
||||
Transform transform;
|
||||
TransformState transformState;
|
||||
Style style{fileSource, 1};
|
||||
AnnotationManager annotationManager{style};
|
||||
std::shared_ptr<ImageManager> imageManager = std::make_shared<ImageManager>();
|
||||
std::shared_ptr<GlyphManager> glyphManager = std::make_shared<GlyphManager>();
|
||||
std::shared_ptr<Scheduler> threadPool = Scheduler::GetBackground();
|
||||
TaggedScheduler threadPool;
|
||||
Style style;
|
||||
|
||||
TileParameters tileParameters(MapMode mapMode = MapMode::Continuous) {
|
||||
return {1.0,
|
||||
@@ -75,10 +76,13 @@ public:
|
||||
annotationManager.makeWeakPtr(),
|
||||
imageManager,
|
||||
glyphManager,
|
||||
0};
|
||||
0,
|
||||
threadPool};
|
||||
};
|
||||
|
||||
SourceTest() {
|
||||
SourceTest()
|
||||
: threadPool(Scheduler::GetBackground(), uniqueID),
|
||||
style{fileSource, 1, threadPool} {
|
||||
// Squelch logging.
|
||||
Log::setObserver(std::make_unique<Log::NullObserver>());
|
||||
|
||||
@@ -88,7 +92,7 @@ public:
|
||||
transformState = transform.getState();
|
||||
}
|
||||
|
||||
~SourceTest() { threadPool->waitForEmpty(); }
|
||||
~SourceTest() { threadPool.waitForEmpty(); }
|
||||
|
||||
void run() { loop.run(); }
|
||||
|
||||
@@ -783,8 +787,8 @@ public:
|
||||
MOCK_METHOD1(tileSetNecessity, void(TileNecessity));
|
||||
MOCK_METHOD1(tileSetMinimumUpdateInterval, void(Duration));
|
||||
|
||||
explicit FakeTileSource(Immutable<style::Source::Impl> impl_, std::shared_ptr<Scheduler> threadPool_)
|
||||
: RenderTileSetSource(std::move(impl_), std::move(threadPool_)) {}
|
||||
explicit FakeTileSource(Immutable<style::Source::Impl> impl_, const TaggedScheduler& threadPool_)
|
||||
: RenderTileSetSource(std::move(impl_), threadPool_) {}
|
||||
void updateInternal(const Tileset& tileset,
|
||||
const std::vector<Immutable<style::LayerProperties>>& layers,
|
||||
const bool needsRendering,
|
||||
@@ -887,8 +891,8 @@ TEST(Source, RenderTileSetSourceUpdate) {
|
||||
|
||||
class FakeRenderTileSetSource : public RenderTileSetSource {
|
||||
public:
|
||||
explicit FakeRenderTileSetSource(Immutable<style::Source::Impl> impl_, std::shared_ptr<Scheduler> threadPool_)
|
||||
: RenderTileSetSource(std::move(impl_), std::move(threadPool_)) {}
|
||||
explicit FakeRenderTileSetSource(Immutable<style::Source::Impl> impl_, TaggedScheduler threadPool_)
|
||||
: RenderTileSetSource(std::move(impl_), threadPool_) {}
|
||||
|
||||
MOCK_METHOD0(mockedUpdateInternal, void());
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ TEST(Style, Properties) {
|
||||
util::RunLoop loop;
|
||||
|
||||
auto fileSource = std::make_shared<StubFileSource>();
|
||||
Style::Impl style{fileSource, 1.0};
|
||||
Style::Impl style{fileSource, 1.0, {Scheduler::GetBackground(), {}}};
|
||||
|
||||
style.loadJSON(R"STYLE({"name": "Test"})STYLE");
|
||||
ASSERT_EQ("Test", style.getName());
|
||||
@@ -65,7 +65,7 @@ TEST(Style, DuplicateSource) {
|
||||
util::RunLoop loop;
|
||||
|
||||
auto fileSource = std::make_shared<StubFileSource>();
|
||||
Style::Impl style{fileSource, 1.0};
|
||||
Style::Impl style{fileSource, 1.0, {Scheduler::GetBackground(), {}}};
|
||||
|
||||
style.loadJSON(util::read_file("test/fixtures/resources/style-unused-sources.json"));
|
||||
|
||||
@@ -85,7 +85,7 @@ TEST(Style, RemoveSourceInUse) {
|
||||
FixtureLog log;
|
||||
|
||||
auto fileSource = std::make_shared<StubFileSource>();
|
||||
Style::Impl style{fileSource, 1.0};
|
||||
Style::Impl style{fileSource, 1.0, {Scheduler::GetBackground(), {}}};
|
||||
|
||||
style.loadJSON(util::read_file("test/fixtures/resources/style-unused-sources.json"));
|
||||
style.addSource(std::make_unique<VectorSource>("sourceId", "mptiler://tiles/contours"));
|
||||
@@ -113,7 +113,7 @@ TEST(Style, RemoveSourceInUse) {
|
||||
TEST(Style, SourceImplsOrder) {
|
||||
util::RunLoop loop;
|
||||
auto fileSource = std::make_shared<StubFileSource>();
|
||||
Style::Impl style{fileSource, 1.0};
|
||||
Style::Impl style{fileSource, 1.0, {Scheduler::GetBackground(), {}}};
|
||||
|
||||
style.addSource(std::make_unique<VectorSource>("c", "mptiler://tiles/contours"));
|
||||
style.addSource(std::make_unique<VectorSource>("b", "mptiler://tiles/contours"));
|
||||
@@ -135,7 +135,7 @@ TEST(Style, SourceImplsOrder) {
|
||||
TEST(Style, AddRemoveImage) {
|
||||
util::RunLoop loop;
|
||||
auto fileSource = std::make_shared<StubFileSource>();
|
||||
Style::Impl style{fileSource, 1.0};
|
||||
Style::Impl style{fileSource, 1.0, {Scheduler::GetBackground(), {}}};
|
||||
style.addImage(std::make_unique<style::Image>("one", PremultipliedImage({16, 16}), 2.0f));
|
||||
style.addImage(std::make_unique<style::Image>("two", PremultipliedImage({16, 16}), 2.0f));
|
||||
style.addImage(std::make_unique<style::Image>("three", PremultipliedImage({16, 16}), 2.0f));
|
||||
@@ -152,7 +152,7 @@ TEST(Style, AddRemoveRemoveImage) {
|
||||
// regression test for https://github.com/mapbox/mapbox-gl-native/pull/16391
|
||||
util::RunLoop loop;
|
||||
auto fileSource = std::make_shared<StubFileSource>();
|
||||
Style::Impl style{fileSource, 1.0};
|
||||
Style::Impl style{fileSource, 1.0, {Scheduler::GetBackground(), {}}};
|
||||
style.addImage(std::make_unique<style::Image>("one", PremultipliedImage({16, 16}), 2.0f));
|
||||
style.addImage(std::make_unique<style::Image>("two", PremultipliedImage({16, 16}), 2.0f));
|
||||
style.addImage(std::make_unique<style::Image>("three", PremultipliedImage({16, 16}), 2.0f));
|
||||
|
||||
@@ -292,7 +292,7 @@ TEST(Layer, DuplicateLayer) {
|
||||
|
||||
// Setup style
|
||||
auto fileSource = std::make_shared<StubFileSource>();
|
||||
Style::Impl style{fileSource, 1.0};
|
||||
Style::Impl style{fileSource, 1.0, {Scheduler::GetBackground(), {}}};
|
||||
style.loadJSON(util::read_file("test/fixtures/resources/style-unused-sources.json"));
|
||||
|
||||
// Add initial layer
|
||||
@@ -313,7 +313,7 @@ TEST(Layer, IncompatibleLayer) {
|
||||
|
||||
// Setup style
|
||||
auto fileSource = std::make_shared<StubFileSource>();
|
||||
Style::Impl style{fileSource, 1.0};
|
||||
Style::Impl style{fileSource, 1.0, {Scheduler::GetBackground(), {}}};
|
||||
style.loadJSON(util::read_file("test/fixtures/resources/style-unused-sources.json"));
|
||||
|
||||
// Try to add duplicate
|
||||
|
||||
Reference in New Issue
Block a user