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

@@ -67,11 +67,12 @@ public:
// From Scheduler. Schedules by using callbacks to the
// JVM to process the mailbox on the right thread.
void schedule(std::function<void()>&& scheduled) override;
void schedule(const util::SimpleIdentity, std::function<void()>&& fn) override { schedule(std::move(fn)); };
mapbox::base::WeakPtr<Scheduler> makeWeakPtr() override { return weakFactory.makeWeakPtr(); }
// Wait for the queue to be empty
// A timeout of zero results in an unbounded wait
std::size_t waitForEmpty(Milliseconds timeout) override;
void waitForEmpty(const util::SimpleIdentity tag) override;
void requestRender();
@@ -79,6 +80,9 @@ public:
using SnapshotCallback = std::function<void(PremultipliedImage)>;
void requestSnapshot(SnapshotCallback);
AndroidRendererBackend& getRendererBackend() const { return *backend; }
const TaggedScheduler& getThreadPool() const { return threadPool; }
protected:
// Called from the GL Thread //
@@ -119,7 +123,7 @@ private:
float pixelRatio;
std::optional<std::string> localIdeographFontFamily;
std::shared_ptr<ThreadPool> threadPool;
TaggedScheduler threadPool;
const MailboxData mailboxData;
std::mutex initialisationMutex;