[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:
committed by
Ivo van Dongen
parent
d88567ee09
commit
edaa002c3c
19
src/mbgl/actor/scheduler.cpp
Normal file
19
src/mbgl/actor/scheduler.cpp
Normal 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
|
||||
Reference in New Issue
Block a user