File tree 3 files changed +24
-26
lines changed
3 files changed +24
-26
lines changed Original file line number Diff line number Diff line change @@ -14,26 +14,6 @@ namespace Babylon::Polyfills::Internal
14
14
}
15
15
}
16
16
17
- struct TimeoutDispatcher ::Timeout
18
- {
19
- TimeoutId id;
20
-
21
- // Make this non-shared when JsRuntime::Dispatch supports it.
22
- std::shared_ptr<Napi::FunctionReference> function;
23
-
24
- TimePoint time;
25
-
26
- Timeout (TimeoutId id, std::shared_ptr<Napi::FunctionReference> function, TimePoint time)
27
- : id{id}
28
- , function{std::move (function)}
29
- , time{time }
30
- {
31
- }
32
-
33
- Timeout (const Timeout&) = delete ;
34
- Timeout (Timeout&&) = delete ;
35
- };
36
-
37
17
TimeoutDispatcher::TimeoutDispatcher (Babylon::JsRuntime& runtime)
38
18
: m_runtimeScheduler{runtime}
39
19
, m_thread{std::thread{&TimeoutDispatcher::ThreadFunction, this }}
@@ -56,7 +36,7 @@ namespace Babylon::Polyfills::Internal
56
36
m_runtimeScheduler.Rundown ();
57
37
}
58
38
59
- TimeoutDispatcher:: TimeoutId TimeoutDispatcher::Dispatch (std::shared_ptr<Napi::FunctionReference> function, std::chrono::milliseconds delay)
39
+ TimeoutId TimeoutDispatcher::Dispatch (std::shared_ptr<Napi::FunctionReference> function, std::chrono::milliseconds delay)
60
40
{
61
41
if (delay.count () < 0 )
62
42
{
@@ -107,7 +87,7 @@ namespace Babylon::Polyfills::Internal
107
87
}
108
88
}
109
89
110
- TimeoutDispatcher:: TimeoutId TimeoutDispatcher::NextTimeoutId ()
90
+ TimeoutId TimeoutDispatcher::NextTimeoutId ()
111
91
{
112
92
while (true )
113
93
{
Original file line number Diff line number Diff line change 13
13
14
14
namespace Babylon ::Polyfills::Internal
15
15
{
16
+ using TimeoutId = int32_t ;
17
+
16
18
class TimeoutDispatcher
17
19
{
18
- using TimeoutId = int32_t ;
19
- struct Timeout ;
20
-
21
20
public:
22
21
TimeoutDispatcher (Babylon::JsRuntime& runtime);
23
22
~TimeoutDispatcher ();
@@ -28,6 +27,26 @@ namespace Babylon::Polyfills::Internal
28
27
private:
29
28
using TimePoint = std::chrono::time_point<std::chrono::steady_clock, std::chrono::microseconds>;
30
29
30
+ struct Timeout
31
+ {
32
+ TimeoutId id;
33
+
34
+ // Make this non-shared when JsRuntime::Dispatch supports it.
35
+ std::shared_ptr<Napi::FunctionReference> function;
36
+
37
+ TimePoint time;
38
+
39
+ Timeout (TimeoutId id, std::shared_ptr<Napi::FunctionReference> function, TimePoint time)
40
+ : id{id}
41
+ , function{std::move (function)}
42
+ , time{time }
43
+ {
44
+ }
45
+
46
+ Timeout (const Timeout&) = delete ;
47
+ Timeout (Timeout&&) = delete ;
48
+ };
49
+
31
50
TimeoutId NextTimeoutId ();
32
51
void ThreadFunction ();
33
52
void CallFunction (std::shared_ptr<Napi::FunctionReference> function);
Original file line number Diff line number Diff line change 2
2
3
3
#include < Babylon/JsRuntimeScheduler.h>
4
4
#include " TimeoutDispatcher.h"
5
- #include < optional>
6
5
7
6
namespace Babylon ::Polyfills::Internal
8
7
{
You can’t perform that action at this time.
0 commit comments