From 7248f94aa3769df0897b0c4ebdb432912ab3f956 Mon Sep 17 00:00:00 2001 From: Mariano Guerra Date: Fri, 8 Feb 2013 17:50:25 +0100 Subject: [PATCH] add call-timeout function docs in README --- README.rest | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/README.rest b/README.rest index e336583..78ad7a6 100644 --- a/README.rest +++ b/README.rest @@ -131,13 +131,29 @@ or if you don't need the internal parameters:: (js/set! scope "add" (js/wrap-plain-fn add)) (js/eval scope "add(1, 2)") 3.0))) -excecute code with timeout:: +execute code with timeout:: (def scope (js/new-safe-scope)) (js/eval-timeout scope "while (true);" 1000) ; will throw a Error exception +call function with timeout:: + + user=> (def f (js/compile-function scope "function () { while(true); }")) + #'user/f + user=> (js/call-timeout scope f 1000) + TimeOutError + org.marianoguerra.rhino.TimedContextFactory.observeInstructionCount + (TimedContextFactory.java:47) + + ; function that doesn't timeout + user=> (def f1 (js/compile-function scope "function (a, b) { return a + + b; }")) + #'user/f1 + user=> (js/call-timeout scope f1 1000 1 3) + 4.0 + license? --------