From aa2598ffff496acbc284d9572e9c01ee25858c1f Mon Sep 17 00:00:00 2001 From: jules Date: Thu, 23 Feb 2017 09:38:45 +0000 Subject: [PATCH] Added method JavascriptEngine::stop() --- modules/juce_core/javascript/juce_Javascript.cpp | 3 ++- modules/juce_core/javascript/juce_Javascript.h | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) 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;