diff --git a/modules/juce_core/javascript/juce_Javascript.cpp b/modules/juce_core/javascript/juce_Javascript.cpp index 089adc8524..cd6a73c8de 100644 --- a/modules/juce_core/javascript/juce_Javascript.cpp +++ b/modules/juce_core/javascript/juce_Javascript.cpp @@ -222,7 +222,7 @@ struct JavascriptEngine::RootObject : public DynamicObject void checkTimeOut (const CodeLocation& location) const { if (Time::getCurrentTime() > root->timeout) - location.throwError ("Execution timed-out"); + location.throwError (root->timeout == Time() ? "Interrupted" : "Execution timed-out"); } }; @@ -1794,6 +1794,7 @@ JavascriptEngine::JavascriptEngine() : maximumExecutionTime (15.0), root (new R JavascriptEngine::~JavascriptEngine() {} void JavascriptEngine::prepareTimeout() const noexcept { root->timeout = Time::getCurrentTime() + maximumExecutionTime; } +void JavascriptEngine::stop() noexcept { root->timeout = {}; } void JavascriptEngine::registerNativeObject (const Identifier& name, DynamicObject* object) { diff --git a/modules/juce_core/javascript/juce_Javascript.h b/modules/juce_core/javascript/juce_Javascript.h index de605f074a..13286c0fee 100644 --- a/modules/juce_core/javascript/juce_Javascript.h +++ b/modules/juce_core/javascript/juce_Javascript.h @@ -98,6 +98,9 @@ public: */ RelativeTime maximumExecutionTime; + /** When called from another thread, causes the interpreter to time-out as soon as possible */ + void stop() noexcept; + /** Provides access to the set of properties of the root namespace object. */ const NamedValueSet& getRootObjectProperties() const noexcept;