[core] current scheduler

- Adds a way to set the current scheduler on the thread to be used whenever a mailbox is created that needs to reply on this thread
This commit is contained in:
Ivo van Dongen
2017-07-25 15:46:16 +03:00
committed by Ivo van Dongen
parent d88567ee09
commit edaa002c3c
4 changed files with 30 additions and 7 deletions

View File

@@ -0,0 +1,19 @@
#include <mbgl/actor/scheduler.hpp>
#include <mbgl/util/thread_local.hpp>
namespace mbgl {
static auto& current() {
static util::ThreadLocal<Scheduler> scheduler;
return scheduler;
};
void Scheduler::SetCurrent(Scheduler* scheduler) {
current().set(scheduler);
}
Scheduler* Scheduler::GetCurrent() {
return current().get();
}
} //namespace mbgl