File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -54,8 +54,17 @@ Platform::Platform() :
5454 */
5555Platform::~Platform ()
5656{
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 ;
5968
6069 // signal the thread in case it is waiting for input
6170 _condition.notify_one ();
@@ -159,8 +168,8 @@ void Platform::shutdown()
159168 // still not set, we need to create it now
160169 if (result != nullptr )
161170 {
162- // create the platform
163- delete result;
171+ // we need to stop the platform before disposing and shutting it down
172+ result-> stop () ;
164173
165174 // and shut down the engine (this also takes care of the ICU) and the platform
166175 v8::V8::Dispose ();
@@ -171,7 +180,10 @@ void Platform::shutdown()
171180
172181 // store the new platform
173182 platform.store (nullptr , std::memory_order_relaxed);
174- }
183+
184+ // delete the platform
185+ delete result;
186+ }
175187 }
176188}
177189
Original file line number Diff line number Diff line change @@ -63,6 +63,11 @@ class Platform : public v8::Platform
6363 * @var std::thread
6464 */
6565 std::thread _worker;
66+
67+ /* *
68+ * (blocking) method to stop running a platform.
69+ */
70+ void stop ();
6671
6772 /* *
6873 * 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)
8383 // the value can be of many types
8484 switch (input.type ())
8585 {
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 ;
8787 case Php::Type::Numeric: result = v8::Integer::New (Isolate::get (), input); break ;
8888 case Php::Type::Float: result = v8::Number::New (Isolate::get (), input); break ;
8989 case Php::Type::Bool: result = v8::Boolean::New (Isolate::get (), input); break ;
You can’t perform that action at this time.
0 commit comments