Skip to content

Commit

Permalink
Use thread_local for thread local scheduler (#2863)
Browse files Browse the repository at this point in the history
  • Loading branch information
louwers authored Sep 23, 2024
1 parent 84ca231 commit c19bb7a
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/mbgl/actor/scheduler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,16 @@ std::function<void()> Scheduler::bindOnce(std::function<void()> fn) {
}

namespace {
auto& current() {
static util::ThreadLocal<Scheduler> scheduler;
return scheduler;
}

thread_local Scheduler* localScheduler;
} // namespace

void Scheduler::SetCurrent(Scheduler* scheduler) {
current().set(scheduler);
localScheduler = scheduler;
}

Scheduler* Scheduler::GetCurrent() {
return current().get();
return localScheduler;
}

// static
Expand Down

0 comments on commit c19bb7a

Please sign in to comment.