/** * Executes the specified function allocating objects on the stack; the function result is copied * to calling context. */ public static <P, R extends Copyable<R>> R execute(Function<P, R> function, P parameter) { StackContext ctx = StackContext.enter(); try { return ctx.executeInContext(function, parameter); } finally { ctx.exit(); } }
/** Executes the specified logic allocating objects on the stack. */ public static void execute(Runnable logic) { StackContext ctx = StackContext.enter(); try { ctx.executeInContext(logic); } finally { ctx.exit(); } }