File tree Expand file tree Collapse file tree 3 files changed +23
-6
lines changed Expand file tree Collapse file tree 3 files changed +23
-6
lines changed Original file line number Diff line number Diff line change @@ -54,8 +54,17 @@ Platform::Platform() :
54
54
*/
55
55
Platform::~Platform ()
56
56
{
57
- // we are no longer running
58
- _running = false ;
57
+ // we stop the platform first
58
+ stop ();
59
+ }
60
+
61
+ /* *
62
+ * Stop running the platform.
63
+ */
64
+ void Platform::stop ()
65
+ {
66
+ // we set it to false, but if the old value was not true then we leap out
67
+ if (!_running.exchange (false )) return ;
59
68
60
69
// signal the thread in case it is waiting for input
61
70
_condition.notify_one ();
@@ -159,8 +168,8 @@ void Platform::shutdown()
159
168
// still not set, we need to create it now
160
169
if (result != nullptr )
161
170
{
162
- // create the platform
163
- delete result;
171
+ // we need to stop the platform before disposing and shutting it down
172
+ result-> stop () ;
164
173
165
174
// and shut down the engine (this also takes care of the ICU) and the platform
166
175
v8::V8::Dispose ();
@@ -171,7 +180,10 @@ void Platform::shutdown()
171
180
172
181
// store the new platform
173
182
platform.store (nullptr , std::memory_order_relaxed);
174
- }
183
+
184
+ // delete the platform
185
+ delete result;
186
+ }
175
187
}
176
188
}
177
189
Original file line number Diff line number Diff line change @@ -63,6 +63,11 @@ class Platform : public v8::Platform
63
63
* @var std::thread
64
64
*/
65
65
std::thread _worker;
66
+
67
+ /* *
68
+ * (blocking) method to stop running a platform.
69
+ */
70
+ void stop ();
66
71
67
72
/* *
68
73
* Execute some work, this is called
Original file line number Diff line number Diff line change @@ -83,7 +83,7 @@ v8::Handle<v8::Value> value(const Php::Value &input)
83
83
// the value can be of many types
84
84
switch (input.type ())
85
85
{
86
- case Php::Type::Null: /* don't set anything, let it be empty */ break ;
86
+ case Php::Type::Null: result = v8::Null ( Isolate::get ()); break ;
87
87
case Php::Type::Numeric: result = v8::Integer::New (Isolate::get (), input); break ;
88
88
case Php::Type::Float: result = v8::Number::New (Isolate::get (), input); break ;
89
89
case Php::Type::Bool: result = v8::Boolean::New (Isolate::get (), input); break ;
You can’t perform that action at this time.
0 commit comments