@Deprecated private MRIRecursionGuard oldRecursionGuard() { MRIRecursionGuard mriRecursionGuard = this.mriRecursionGuard; if (mriRecursionGuard != null) return mriRecursionGuard; synchronized (this) { mriRecursionGuard = this.mriRecursionGuard; if (mriRecursionGuard != null) return mriRecursionGuard; return mriRecursionGuard = new MRIRecursionGuard(this); } }
@Deprecated public IRubyObject execRecursiveOuter(RecursiveFunction func, IRubyObject obj) { try { return execRecursiveInternal(func, obj, null, true); } finally { recursiveListClear(); } }
private IRubyObject execRecursiveI(ExecRecursiveParams p) { IRubyObject result = null; recursivePush(p.list, p.objid, p.pairid); try { result = p.func.call(p.obj, false); } finally { recursivePop(p.list, p.objid, p.pairid); } return result; }
@Deprecated private IRubyObject execRecursiveInternal(RecursiveFunction func, IRubyObject obj, IRubyObject pairid, boolean outer) { ExecRecursiveParams p = new ExecRecursiveParams(); p.list = recursiveListAccess(); p.objid = obj.id(); boolean outermost = outer && !recursiveCheck(p.list, recursiveKey, null); if(recursiveCheck(p.list, p.objid, pairid)) { if(outer && !outermost) { throw new RecursiveError(p.list); recursivePush(p.list, recursiveKey, null); try { result = execRecursiveI(p); } catch(RecursiveError e) { if(e.tag != p.list) { recursivePop(p.list, recursiveKey, null); if(result == p.list) { result = func.call(obj, true); result = execRecursiveI(p);
@Deprecated public IRubyObject execRecursive(RecursiveFunction func, IRubyObject obj) { if (!inRecursiveListOperation.get()) { throw runtime.newThreadError("BUG: execRecursive called outside recursiveListOperation"); } return execRecursiveInternal(func, obj, null, false); }
@Deprecated public <T extends IRubyObject> T recursiveListOperation(Callable<T> body) { try { inRecursiveListOperation.set(true); return body.call(); } catch (Exception e) { Helpers.throwException(e); return null; // not reached } finally { recursiveListClear(); inRecursiveListOperation.set(false); } }
/** * Begin a recursive walk that may make one or more calls to * {@link Ruby#execRecursive(org.jruby.Ruby.RecursiveFunction, org.jruby.runtime.builtin.IRubyObject) execRecursive}. * Clean up recursive structures once complete. * * @param body * @param <T> * @return */ @Deprecated public <T extends IRubyObject> T recursiveListOperation(Callable<T> body) { return oldRecursionGuard().recursiveListOperation(body); }
/** * Perform a recursive walk on the given object using the given function. * * Do not call this method directly unless you know you're within a call * to {@link Ruby#recursiveListOperation(java.util.concurrent.Callable) recursiveListOperation}, * which will ensure the thread-local recursion tracking data structs are * cleared. * * MRI: rb_exec_recursive * * Calls func(obj, arg, recursive), where recursive is non-zero if the * current method is called recursively on obj * * @param func * @param obj * @return */ @Deprecated public IRubyObject execRecursive(RecursiveFunction func, IRubyObject obj) { return oldRecursionGuard().execRecursive(func, obj); }
/** * Perform a recursive walk on the given object using the given function. * Treat this as the outermost call, cleaning up recursive structures. * * MRI: rb_exec_recursive_outer * * If recursion is detected on the current method and obj, the outermost * func will be called with (obj, arg, Qtrue). All inner func will be * short-circuited using throw. * * @deprecated Use ThreadContext.safeRecurse. * * @param func * @param obj * @return */ @Deprecated public IRubyObject execRecursiveOuter(RecursiveFunction func, IRubyObject obj) { return oldRecursionGuard().execRecursiveOuter(func, obj); }
@Deprecated private IRubyObject execRecursiveInternal(RecursiveFunction func, IRubyObject obj, IRubyObject pairid, boolean outer) { ExecRecursiveParams p = new ExecRecursiveParams(); p.list = recursiveListAccess(); p.objid = obj.id(); boolean outermost = outer && !recursiveCheck(p.list, recursiveKey, null); if(recursiveCheck(p.list, p.objid, pairid)) { if(outer && !outermost) { throw new RecursiveError(p.list); recursivePush(p.list, recursiveKey, null); try { result = execRecursiveI(p); } catch(RecursiveError e) { if(e.tag != p.list) { recursivePop(p.list, recursiveKey, null); if(result == p.list) { result = func.call(obj, true); result = execRecursiveI(p);
@Deprecated public IRubyObject execRecursive(RecursiveFunction func, IRubyObject obj) { if (!inRecursiveListOperation.get()) { throw runtime.newThreadError("BUG: execRecursive called outside recursiveListOperation"); } return execRecursiveInternal(func, obj, null, false); }
@Deprecated public <T extends IRubyObject> T recursiveListOperation(Callable<T> body) { try { inRecursiveListOperation.set(true); return body.call(); } catch (Exception e) { Helpers.throwException(e); return null; // not reached } finally { recursiveListClear(); inRecursiveListOperation.set(false); } }
/** * Begin a recursive walk that may make one or more calls to * {@link Ruby#execRecursive(org.jruby.Ruby.RecursiveFunction, org.jruby.runtime.builtin.IRubyObject) execRecursive}. * Clean up recursive structures once complete. * * @param body * @param <T> * @return */ @Deprecated public <T extends IRubyObject> T recursiveListOperation(Callable<T> body) { return oldRecursionGuard().recursiveListOperation(body); }
/** * Perform a recursive walk on the given object using the given function. * * Do not call this method directly unless you know you're within a call * to {@link Ruby#recursiveListOperation(java.util.concurrent.Callable) recursiveListOperation}, * which will ensure the thread-local recursion tracking data structs are * cleared. * * MRI: rb_exec_recursive * * Calls func(obj, arg, recursive), where recursive is non-zero if the * current method is called recursively on obj * * @param func * @param obj * @return */ @Deprecated public IRubyObject execRecursive(RecursiveFunction func, IRubyObject obj) { return oldRecursionGuard().execRecursive(func, obj); }
/** * Perform a recursive walk on the given object using the given function. * Treat this as the outermost call, cleaning up recursive structures. * * MRI: rb_exec_recursive_outer * * If recursion is detected on the current method and obj, the outermost * func will be called with (obj, arg, Qtrue). All inner func will be * short-circuited using throw. * * @deprecated Use ThreadContext.safeRecurse. * * @param func * @param obj * @return */ @Deprecated public IRubyObject execRecursiveOuter(RecursiveFunction func, IRubyObject obj) { return oldRecursionGuard().execRecursiveOuter(func, obj); }
private IRubyObject execRecursiveI(ExecRecursiveParams p) { IRubyObject result = null; recursivePush(p.list, p.objid, p.pairid); try { result = p.func.call(p.obj, false); } finally { recursivePop(p.list, p.objid, p.pairid); } return result; }
@Deprecated public IRubyObject execRecursiveOuter(RecursiveFunction func, IRubyObject obj) { try { return execRecursiveInternal(func, obj, null, true); } finally { recursiveListClear(); } }
@Deprecated private MRIRecursionGuard oldRecursionGuard() { MRIRecursionGuard mriRecursionGuard = this.mriRecursionGuard; if (mriRecursionGuard != null) return mriRecursionGuard; synchronized (this) { mriRecursionGuard = this.mriRecursionGuard; if (mriRecursionGuard != null) return mriRecursionGuard; return mriRecursionGuard = new MRIRecursionGuard(this); } }