1 package org.simantics.scl.runtime.procedure;
5 import org.simantics.scl.runtime.function.Function;
6 import org.simantics.scl.runtime.function.FunctionImpl1;
7 import org.simantics.scl.runtime.tuple.Tuple0;
10 public class Procedures {
11 public static boolean isInterrupted() {
12 return Thread.currentThread().isInterrupted();
15 public static void checkInterrupted() throws InterruptedException {
16 if(Thread.interrupted())
17 throw new InterruptedException();
20 public static String generateUID() {
21 return UUID.randomUUID().toString();
24 private static Function runProc = new FunctionImpl1() {
26 public Object apply(Object f) {
27 return ((Function)f).apply(Tuple0.INSTANCE);
31 public static Function runProc() {
35 public static Object catch_(Class<?> exceptionClass, Function expression, Function handler) throws Throwable {
37 return expression.apply(Tuple0.INSTANCE);
38 } catch(Throwable e) {
39 if(exceptionClass.isAssignableFrom(e.getClass()))
40 return handler.apply(e);