Skip to content

Commit

Permalink
Fix Android build
Browse files Browse the repository at this point in the history
  • Loading branch information
bghgary committed Oct 28, 2022
1 parent 309c4d9 commit ad88d30
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 26 deletions.
24 changes: 2 additions & 22 deletions Polyfills/Window/Source/TimeoutDispatcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<Napi::FunctionReference> function;

TimePoint time;

Timeout(TimeoutId id, std::shared_ptr<Napi::FunctionReference> 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}}
Expand All @@ -56,7 +36,7 @@ namespace Babylon::Polyfills::Internal
m_runtimeScheduler.Rundown();
}

TimeoutDispatcher::TimeoutId TimeoutDispatcher::Dispatch(std::shared_ptr<Napi::FunctionReference> function, std::chrono::milliseconds delay)
TimeoutId TimeoutDispatcher::Dispatch(std::shared_ptr<Napi::FunctionReference> function, std::chrono::milliseconds delay)
{
if (delay.count() < 0)
{
Expand Down Expand Up @@ -107,7 +87,7 @@ namespace Babylon::Polyfills::Internal
}
}

TimeoutDispatcher::TimeoutId TimeoutDispatcher::NextTimeoutId()
TimeoutId TimeoutDispatcher::NextTimeoutId()
{
while (true)
{
Expand Down
25 changes: 22 additions & 3 deletions Polyfills/Window/Source/TimeoutDispatcher.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -28,6 +27,26 @@ namespace Babylon::Polyfills::Internal
private:
using TimePoint = std::chrono::time_point<std::chrono::steady_clock, std::chrono::microseconds>;

struct Timeout
{
TimeoutId id;

// Make this non-shared when JsRuntime::Dispatch supports it.
std::shared_ptr<Napi::FunctionReference> function;

TimePoint time;

Timeout(TimeoutId id, std::shared_ptr<Napi::FunctionReference> 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<Napi::FunctionReference> function);
Expand Down
1 change: 0 additions & 1 deletion Polyfills/Window/Source/Window.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

#include <Babylon/JsRuntimeScheduler.h>
#include "TimeoutDispatcher.h"
#include <optional>

namespace Babylon::Polyfills::Internal
{
Expand Down

0 comments on commit ad88d30

Please sign in to comment.