Add TaggedScheduler, couple lifetime of tasks and orchestrator (#2398)

This commit is contained in:
mwilsnd
2024-06-28 17:20:03 -04:00
committed by GitHub
parent b2fe5021b8
commit c4c75452b6
99 changed files with 759 additions and 489 deletions

View File

@@ -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());