diff --git a/include/mbgl/actor/scheduler.hpp b/include/mbgl/actor/scheduler.hpp index 69a875adbda..8b2f81f22b8 100644 --- a/include/mbgl/actor/scheduler.hpp +++ b/include/mbgl/actor/scheduler.hpp @@ -80,7 +80,8 @@ class Scheduler { virtual void waitForEmpty(const util::SimpleIdentity = util::SimpleIdentity::Empty) = 0; /// Set/Get the current Scheduler for this thread - static Scheduler* GetCurrent(); + /// @param init initialize if missing + static Scheduler* GetCurrent(bool init = true); static void SetCurrent(Scheduler*); /// Get the scheduler for asynchronous tasks. This method diff --git a/platform/android/MapLibreAndroid/src/cpp/jni_native.cpp b/platform/android/MapLibreAndroid/src/cpp/jni_native.cpp index e8d7041e25b..ce343c48d23 100644 --- a/platform/android/MapLibreAndroid/src/cpp/jni_native.cpp +++ b/platform/android/MapLibreAndroid/src/cpp/jni_native.cpp @@ -68,8 +68,6 @@ void registerNatives(JavaVM* vm) { jni::JNIEnv& env = jni::GetEnv(*vm, jni::jni_version_1_6); - // For the FileSource - static mbgl::util::RunLoop mainRunLoop; FileSource::registerNative(env); // Basic types diff --git a/platform/darwin/src/run_loop.cpp b/platform/darwin/src/run_loop.cpp index a8619116a3a..24a93d31517 100644 --- a/platform/darwin/src/run_loop.cpp +++ b/platform/darwin/src/run_loop.cpp @@ -21,7 +21,7 @@ RunLoop* RunLoop::Get() { RunLoop::RunLoop(Type) : impl(std::make_unique()) { - assert(!Scheduler::GetCurrent()); + assert(!Scheduler::GetCurrent(false)); Scheduler::SetCurrent(this); impl->async = std::make_unique(std::bind(&RunLoop::process, this)); } diff --git a/platform/windows/windows.cmake b/platform/windows/windows.cmake index 96400553954..16736215c3b 100644 --- a/platform/windows/windows.cmake +++ b/platform/windows/windows.cmake @@ -266,6 +266,12 @@ target_link_libraries( $,libuv::uv_a,libuv::uv> ) +target_link_libraries( + mbgl-expression-test + PRIVATE + $,libuv::uv_a,libuv::uv> +) + # Disable benchmarks in CI as they run in VM environment if(NOT DEFINED ENV{CI}) add_test(NAME mbgl-benchmark-runner COMMAND mbgl-benchmark-runner WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}) diff --git a/src/mbgl/actor/scheduler.cpp b/src/mbgl/actor/scheduler.cpp index 515a777848e..707de734ddc 100644 --- a/src/mbgl/actor/scheduler.cpp +++ b/src/mbgl/actor/scheduler.cpp @@ -1,6 +1,7 @@ #include #include #include +#include namespace mbgl { @@ -22,7 +23,11 @@ void Scheduler::SetCurrent(Scheduler* scheduler) { localScheduler = scheduler; } -Scheduler* Scheduler::GetCurrent() { +Scheduler* Scheduler::GetCurrent(bool init) { + if (!localScheduler && init) { + thread_local util::RunLoop runLoop; + SetCurrent(&runLoop); + } return localScheduler; }