From f4f4d13b70cfc26e44c7cbc679acbe9609ae2936 Mon Sep 17 00:00:00 2001 From: Ivo van Dongen Date: Tue, 25 Jul 2017 18:35:38 +0300 Subject: [all] ensure runloop is the current scheduler --- platform/qt/src/run_loop.cpp | 16 +++++----------- platform/qt/src/thread_local.cpp | 4 ++-- 2 files changed, 7 insertions(+), 13 deletions(-) (limited to 'platform/qt/src') diff --git a/platform/qt/src/run_loop.cpp b/platform/qt/src/run_loop.cpp index c44f284852..71ea19032a 100644 --- a/platform/qt/src/run_loop.cpp +++ b/platform/qt/src/run_loop.cpp @@ -1,6 +1,6 @@ #include "run_loop_impl.hpp" -#include +#include #include @@ -8,13 +8,6 @@ #include #include -namespace { - -using namespace mbgl::util; -static ThreadLocal& current = *new ThreadLocal; - -} - namespace mbgl { namespace util { @@ -27,7 +20,8 @@ void RunLoop::Impl::onWriteEvent(int fd) { } RunLoop* RunLoop::Get() { - return current.get(); + assert(static_cast(Scheduler::GetCurrent())); + return static_cast(Scheduler::GetCurrent()); } RunLoop::RunLoop(Type type) : impl(std::make_unique()) { @@ -42,14 +36,14 @@ RunLoop::RunLoop(Type type) : impl(std::make_unique()) { impl->type = type; - current.set(this); + Scheduler::SetCurrent(this); impl->async = std::make_unique(std::bind(&RunLoop::process, this)); } RunLoop::~RunLoop() { MBGL_VERIFY_THREAD(tid); - current.set(nullptr); + Scheduler::SetCurrent(nullptr); } LOOP_HANDLE RunLoop::getLoopHandle() { diff --git a/platform/qt/src/thread_local.cpp b/platform/qt/src/thread_local.cpp index bf2103c98f..467bfb0d05 100644 --- a/platform/qt/src/thread_local.cpp +++ b/platform/qt/src/thread_local.cpp @@ -1,6 +1,6 @@ #include -#include +#include #include #include @@ -41,7 +41,7 @@ void ThreadLocal::set(T* ptr) { impl->local.localData()[0] = ptr; } -template class ThreadLocal; +template class ThreadLocal; template class ThreadLocal; template class ThreadLocal; // For unit tests -- cgit v1.2.1