Skip to content

Commit 9d1e098

Browse files
committed
Fix merge issues
1 parent 204efb9 commit 9d1e098

File tree

4 files changed

+11
-12
lines changed

4 files changed

+11
-12
lines changed

Polyfills/Window/Source/TimeoutDispatcher.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ namespace Babylon::Polyfills::Internal
3434
Timeout(Timeout&&) = delete;
3535
};
3636

37-
TimeoutDispatcher::TimeoutDispatcher(Babylon::JsRuntime& runtime)
38-
: m_runtime{runtime}
37+
TimeoutDispatcher::TimeoutDispatcher(Babylon::JsRuntimeScheduler& runtimeScheduler)
38+
: m_runtimeScheduler{runtimeScheduler}
3939
, m_thread{std::thread{&TimeoutDispatcher::ThreadFunction, this}}
4040
{
4141
}
@@ -71,7 +71,7 @@ namespace Babylon::Polyfills::Internal
7171

7272
if (time <= earliestTime)
7373
{
74-
m_runtime.Dispatch([this](Napi::Env) {
74+
m_runtimeScheduler.Get()([this]() {
7575
m_condVariable.notify_one();
7676
});
7777
}
@@ -158,7 +158,7 @@ namespace Babylon::Polyfills::Internal
158158
{
159159
if (function)
160160
{
161-
m_runtime.Dispatch([function = std::move(function)](Napi::Env)
161+
m_runtimeScheduler.Get()([function = std::move(function)]()
162162
{ function->Call({}); });
163163
}
164164
}

Polyfills/Window/Source/TimeoutDispatcher.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#pragma once
22

3-
#include <Babylon/JsRuntime.h>
3+
#include <Babylon/JsRuntimeScheduler.h>
44
#include <napi/napi.h>
55

66
#include <atomic>
@@ -19,7 +19,7 @@ namespace Babylon::Polyfills::Internal
1919
struct Timeout;
2020

2121
public:
22-
TimeoutDispatcher(Babylon::JsRuntime& runtime);
22+
TimeoutDispatcher(Babylon::JsRuntimeScheduler& runtimeScheduler);
2323
~TimeoutDispatcher();
2424

2525
TimeoutId Dispatch(std::shared_ptr<Napi::FunctionReference> function, std::chrono::milliseconds delay);
@@ -32,7 +32,7 @@ namespace Babylon::Polyfills::Internal
3232
void ThreadFunction();
3333
void CallFunction(std::shared_ptr<Napi::FunctionReference> function);
3434

35-
Babylon::JsRuntime& m_runtime;
35+
Babylon::JsRuntimeScheduler& m_runtimeScheduler;
3636
std::mutex m_mutex{};
3737
std::condition_variable m_condVariable{};
3838
TimeoutId m_lastTimeoutId{0};

Polyfills/Window/Source/Window.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ namespace Babylon::Polyfills::Internal
7272
Window::Window(const Napi::CallbackInfo& info)
7373
: Napi::ObjectWrap<Window>{info}
7474
, m_runtimeScheduler{JsRuntime::GetFromJavaScript(info.Env())}
75-
, m_timeoutDispatcher{m_runtime}
75+
, m_timeoutDispatcher{m_runtimeScheduler}
7676
{
7777
}
7878

@@ -91,10 +91,9 @@ namespace Babylon::Polyfills::Internal
9191
? std::make_shared<Napi::FunctionReference>(Napi::Persistent(info[0].As<Napi::Function>()))
9292
: std::shared_ptr<Napi::FunctionReference>{};
9393

94-
window.RecursiveWaitOrCall(Napi::Persistent(info.This()), std::move(function), std::chrono::system_clock::now() + milliseconds);
9594
auto delay = std::chrono::milliseconds{info[1].ToNumber().Int32Value()};
9695

97-
return Napi::Value::From(info.Env(), window.m_timeoutDispatcher->Dispatch(function, delay));
96+
return Napi::Value::From(info.Env(), window.m_timeoutDispatcher.Dispatch(function, delay));
9897
}
9998

10099
void Window::ClearTimeout(const Napi::CallbackInfo& info)
@@ -104,7 +103,7 @@ namespace Babylon::Polyfills::Internal
104103
{
105104
auto timeoutId = arg.As<Napi::Number>().Int32Value();
106105
auto& window = *static_cast<Window*>(info.Data());
107-
window.m_timeoutDispatcher->Clear(timeoutId);
106+
window.m_timeoutDispatcher.Clear(timeoutId);
108107
}
109108
}
110109

Polyfills/Window/Source/Window.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,6 @@ namespace Babylon::Polyfills::Internal
2727

2828
arcana::cancellation_source m_cancelSource;
2929
JsRuntimeScheduler m_runtimeScheduler;
30-
std::optional<TimeoutDispatcher> m_timeoutDispatcher;
30+
TimeoutDispatcher m_timeoutDispatcher;
3131
};
3232
}

0 commit comments

Comments
 (0)