diff options
author | Langston Smith <langston.smith@mapbox.com> | 2018-01-04 11:15:50 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-01-04 11:15:50 -0800 |
commit | 2ea955d2751ba6459f99a0695e53505c0a11702b (patch) | |
tree | f54450918b634a2eea1bd2c4ebc671bf1bb06106 /platform/default/run_loop.cpp | |
parent | f2ec6ae326bad79fea2b06a21151a2835522572a (diff) | |
parent | c62b0af24fc76b4bb2eb34100611dd3ee9ee5536 (diff) | |
download | qtlocation-mapboxgl-upstream/ls-android-readme-tweaks.tar.gz |
Merge branch 'master' into ls-android-readme-tweaksupstream/ls-android-readme-tweaks
Diffstat (limited to 'platform/default/run_loop.cpp')
-rw-r--r-- | platform/default/run_loop.cpp | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/platform/default/run_loop.cpp b/platform/default/run_loop.cpp index 98d1badcb5..5bccd21d56 100644 --- a/platform/default/run_loop.cpp +++ b/platform/default/run_loop.cpp @@ -1,6 +1,7 @@ #include <mbgl/util/run_loop.hpp> #include <mbgl/util/async_task.hpp> #include <mbgl/util/thread_local.hpp> +#include <mbgl/actor/scheduler.hpp> #include <uv.h> @@ -10,9 +11,6 @@ namespace { -using namespace mbgl::util; -static ThreadLocal<RunLoop>& current = *new ThreadLocal<RunLoop>; - void dummyCallback(uv_async_t*) {} } // namespace @@ -53,7 +51,8 @@ struct Watch { }; RunLoop* RunLoop::Get() { - return current.get(); + assert(static_cast<RunLoop*>(Scheduler::GetCurrent())); + return static_cast<RunLoop*>(Scheduler::GetCurrent()); } class RunLoop::Impl { @@ -98,12 +97,12 @@ RunLoop::RunLoop(Type type) : impl(std::make_unique<Impl>()) { impl->type = type; - current.set(this); + Scheduler::SetCurrent(this); impl->async = std::make_unique<AsyncTask>(std::bind(&RunLoop::process, this)); } RunLoop::~RunLoop() { - current.set(nullptr); + Scheduler::SetCurrent(nullptr); // Close the dummy handle that we have // just to keep the main loop alive. @@ -127,12 +126,14 @@ RunLoop::~RunLoop() { } LOOP_HANDLE RunLoop::getLoopHandle() { - return current.get()->impl->loop; + return Get()->impl->loop; } void RunLoop::push(std::shared_ptr<WorkTask> task) { - withMutex([&] { queue.push(std::move(task)); }); - impl->async->send(); + withMutex([&] { + queue.push(std::move(task)); + impl->async->send(); + }); } void RunLoop::run() { |