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

@@ -100,12 +100,13 @@ TEST(AsyncTask, DestroyAfterSignaling) {
TEST(AsyncTask, RequestCoalescingMultithreaded) {
RunLoop loop;
util::SimpleIdentity id;
unsigned count = 0, numThreads = 25;
AsyncTask async([&count] { ++count; });
std::shared_ptr<Scheduler> retainer = Scheduler::GetBackground();
auto mailbox = std::make_shared<Mailbox>(*retainer);
TaggedScheduler retainer = {Scheduler::GetBackground(), id};
auto mailbox = std::make_shared<Mailbox>(retainer);
TestWorker worker(&async);
ActorRef<TestWorker> workerRef(worker, mailbox);
@@ -127,14 +128,15 @@ TEST(AsyncTask, RequestCoalescingMultithreaded) {
TEST(AsyncTask, ThreadSafety) {
RunLoop loop;
mbgl::util::SimpleIdentity id;
unsigned count = 0, numThreads = 25;
std::atomic_uint completed(numThreads);
AsyncTask async([&count] { ++count; });
std::shared_ptr<Scheduler> retainer = Scheduler::GetBackground();
auto mailbox = std::make_shared<Mailbox>(*retainer);
TaggedScheduler retainer = {Scheduler::GetBackground(), id};
auto mailbox = std::make_shared<Mailbox>(retainer);
TestWorker worker(&async);
ActorRef<TestWorker> workerRef(worker, mailbox);
@@ -168,7 +170,7 @@ TEST(AsyncTask, scheduleAndReplyValue) {
};
std::shared_ptr<Scheduler> sheduler = Scheduler::GetBackground();
sheduler->scheduleAndReplyValue(runInBackground, onResult);
sheduler->scheduleAndReplyValue(util::SimpleIdentity::Empty, runInBackground, onResult);
loop.run();
}