diff --git a/Polyfills/Window/Source/TimeoutDispatcher.cpp b/Polyfills/Window/Source/TimeoutDispatcher.cpp index deb4b437c..fb4bfd863 100644 --- a/Polyfills/Window/Source/TimeoutDispatcher.cpp +++ b/Polyfills/Window/Source/TimeoutDispatcher.cpp @@ -14,26 +14,6 @@ namespace Babylon::Polyfills::Internal } } - struct TimeoutDispatcher::Timeout - { - TimeoutId id; - - // Make this non-shared when JsRuntime::Dispatch supports it. - std::shared_ptr function; - - TimePoint time; - - Timeout(TimeoutId id, std::shared_ptr function, TimePoint time) - : id{id} - , function{std::move(function)} - , time{time} - { - } - - Timeout(const Timeout&) = delete; - Timeout(Timeout&&) = delete; - }; - TimeoutDispatcher::TimeoutDispatcher(Babylon::JsRuntime& runtime) : m_runtimeScheduler{runtime} , m_thread{std::thread{&TimeoutDispatcher::ThreadFunction, this}} @@ -56,7 +36,7 @@ namespace Babylon::Polyfills::Internal m_runtimeScheduler.Rundown(); } - TimeoutDispatcher::TimeoutId TimeoutDispatcher::Dispatch(std::shared_ptr function, std::chrono::milliseconds delay) + TimeoutId TimeoutDispatcher::Dispatch(std::shared_ptr function, std::chrono::milliseconds delay) { if (delay.count() < 0) { @@ -107,7 +87,7 @@ namespace Babylon::Polyfills::Internal } } - TimeoutDispatcher::TimeoutId TimeoutDispatcher::NextTimeoutId() + TimeoutId TimeoutDispatcher::NextTimeoutId() { while (true) { diff --git a/Polyfills/Window/Source/TimeoutDispatcher.h b/Polyfills/Window/Source/TimeoutDispatcher.h index e20509cb2..c92a4da90 100644 --- a/Polyfills/Window/Source/TimeoutDispatcher.h +++ b/Polyfills/Window/Source/TimeoutDispatcher.h @@ -13,11 +13,10 @@ namespace Babylon::Polyfills::Internal { + using TimeoutId = int32_t; + class TimeoutDispatcher { - using TimeoutId = int32_t; - struct Timeout; - public: TimeoutDispatcher(Babylon::JsRuntime& runtime); ~TimeoutDispatcher(); @@ -28,6 +27,26 @@ namespace Babylon::Polyfills::Internal private: using TimePoint = std::chrono::time_point; + struct Timeout + { + TimeoutId id; + + // Make this non-shared when JsRuntime::Dispatch supports it. + std::shared_ptr function; + + TimePoint time; + + Timeout(TimeoutId id, std::shared_ptr function, TimePoint time) + : id{id} + , function{std::move(function)} + , time{time} + { + } + + Timeout(const Timeout&) = delete; + Timeout(Timeout&&) = delete; + }; + TimeoutId NextTimeoutId(); void ThreadFunction(); void CallFunction(std::shared_ptr function); diff --git a/Polyfills/Window/Source/Window.h b/Polyfills/Window/Source/Window.h index 45b3acf54..1690c0e70 100644 --- a/Polyfills/Window/Source/Window.h +++ b/Polyfills/Window/Source/Window.h @@ -2,7 +2,6 @@ #include #include "TimeoutDispatcher.h" -#include namespace Babylon::Polyfills::Internal {