@JRubyMethod(compat = CompatVersion.RUBY1_9) public static IRubyObject chunk(ThreadContext context, IRubyObject self, final IRubyObject initialState, final Block block) { if(!block.isGiven()) { throw context.runtime.newArgumentError("no block given"); } IRubyObject enumerator = context.runtime.getEnumerator().allocate(); enumerator.getInternalVariables().setInternalVariable("chunk_enumerable", self); enumerator.getInternalVariables().setInternalVariable("chunk_categorize", RubyProc.newProc(context.runtime, block, block.type)); enumerator.getInternalVariables().setInternalVariable("chunk_initial_state", initialState); Helpers.invoke(context, enumerator, "initialize", CallBlock.newCallClosure(self, context.runtime.getEnumerable(), Arity.ONE_ARGUMENT, new ChunkedBlockCallback(context.runtime, enumerator), context)); return enumerator; }
private void raiseAnonymous() { // TODO: MRI calls Timeout::Error.catch here with the body of the timeout; we use __identifier__. IRubyObject anonException = getDefaultException(timeout).newInstance(timeout.getRuntime().getCurrentContext(), message, Block.NULL_BLOCK); anonException.getInternalVariables().setInternalVariable("__identifier__", id); currentThread.raise(anonException); }
@JRubyMethod(compat = CompatVersion.RUBY1_9) public static IRubyObject chunk(ThreadContext context, IRubyObject self, final IRubyObject initialState, final Block block) { if(!block.isGiven()) { throw context.runtime.newArgumentError("no block given"); } IRubyObject enumerator = context.runtime.getEnumerator().allocate(); enumerator.getInternalVariables().setInternalVariable("chunk_enumerable", self); enumerator.getInternalVariables().setInternalVariable("chunk_categorize", RubyProc.newProc(context.runtime, block, block.type)); enumerator.getInternalVariables().setInternalVariable("chunk_initial_state", initialState); Helpers.invoke(context, enumerator, "initialize", CallBlock.newCallClosure(self, context.runtime.getEnumerable(), Arity.ONE_ARGUMENT, new ChunkedBlockCallback(context.runtime, enumerator), context)); return enumerator; }
private void raiseAnonymous() { // TODO: MRI calls Timeout::Error.catch here with the body of the timeout; we use __identifier__. IRubyObject anonException = getDefaultException(timeout).newInstance(timeout.getRuntime().getCurrentContext(), message, Block.NULL_BLOCK); anonException.getInternalVariables().setInternalVariable("__identifier__", id); currentThread.raise(anonException); }
public void run() { if (latch.compareAndSet(false, true)) { if (currentThread.alive_p().isTrue()) { RubyClass anonException = (RubyClass)runtime.getClassFromPath("Timeout::AnonymousException"); IRubyObject anonExceptionObj = anonException.newInstance(runtime.getCurrentContext(), runtime.newString("execution expired"), Block.NULL_BLOCK); anonExceptionObj.getInternalVariables().setInternalVariable("__identifier__", id); currentThread.internalRaise(new IRubyObject[] {anonExceptionObj}); } } } };
public void run() { if (latch.compareAndSet(false, true)) { if (currentThread.alive_p().isTrue()) { RubyClass anonException = (RubyClass)runtime.getClassFromPath("Timeout::AnonymousException"); IRubyObject anonExceptionObj = anonException.newInstance(runtime.getCurrentContext(), runtime.newString("execution expired"), Block.NULL_BLOCK); anonExceptionObj.getInternalVariables().setInternalVariable("__identifier__", id); currentThread.internalRaise(new IRubyObject[] {anonExceptionObj}); } } } };
@JRubyMethod public static IRubyObject chunk(ThreadContext context, IRubyObject self, final Block block) { final Ruby runtime = context.runtime; if(!block.isGiven()) { return enumeratorizeWithSize(context, self, "chunk", enumSizeFn(context, self)); } IRubyObject enumerator = context.runtime.getEnumerator().allocate(); enumerator.getInternalVariables().setInternalVariable("chunk_enumerable", self); enumerator.getInternalVariables().setInternalVariable("chunk_categorize", RubyProc.newProc(context.runtime, block, block.type)); Helpers.invoke(context, enumerator, "initialize", CallBlock.newCallClosure(self, context.runtime.getEnumerable(), Signature.ONE_ARGUMENT, new ChunkedBlockCallback(context.runtime, enumerator), context)); return enumerator; }
@JRubyMethod public static IRubyObject chunk(ThreadContext context, IRubyObject self, final Block block) { final Ruby runtime = context.runtime; if(!block.isGiven()) { return enumeratorizeWithSize(context, self, "chunk", enumSizeFn(context, self)); } IRubyObject enumerator = context.runtime.getEnumerator().allocate(); enumerator.getInternalVariables().setInternalVariable("chunk_enumerable", self); enumerator.getInternalVariables().setInternalVariable("chunk_categorize", RubyProc.newProc(context.runtime, block, block.type)); Helpers.invoke(context, enumerator, "initialize", CallBlock.newCallClosure(self, context.runtime.getEnumerable(), Signature.ONE_ARGUMENT, new ChunkedBlockCallback(context.runtime, enumerator), context)); return enumerator; }
@JRubyMethod(meta = true) public static IRubyObject list(ThreadContext context, IRubyObject recv) { Ruby runtime = recv.getRuntime(); RubyHash names; synchronized (recv) { names = (RubyHash) recv.getInternalVariables().getInternalVariable("signal_list"); if (names == null) { names = RubyHash.newHash(runtime); for (Map.Entry<String, Integer> sig : RubySignal.list().entrySet()) { names.op_aset(context, runtime.freezeAndDedupString(runtime.newString(sig.getKey())), runtime.newFixnum(sig.getValue())); } names.op_aset(context, runtime.freezeAndDedupString(runtime.newString("EXIT")), runtime.newFixnum(0)); recv.getInternalVariables().setInternalVariable("signal_list", names); } else { names.dup(context); } } return names; }
@JRubyMethod(meta = true) public static IRubyObject list(ThreadContext context, IRubyObject recv) { Ruby runtime = recv.getRuntime(); RubyHash names; synchronized (recv) { names = (RubyHash) recv.getInternalVariables().getInternalVariable("signal_list"); if (names == null) { names = RubyHash.newHash(runtime); for (Map.Entry<String, Integer> sig : RubySignal.list().entrySet()) { names.op_aset(context, runtime.freezeAndDedupString(runtime.newString(sig.getKey())), runtime.newFixnum(sig.getValue())); } names.op_aset(context, runtime.freezeAndDedupString(runtime.newString("EXIT")), runtime.newFixnum(0)); recv.getInternalVariables().setInternalVariable("signal_list", names); } else { names.dup(context); } } return names; }
recv.getInternalVariables().setInternalVariable("group_blocking", true); recv.getInternalVariables().setInternalVariable("group_blocking", false);
recv.getInternalVariables().setInternalVariable("group_blocking", true); recv.getInternalVariables().setInternalVariable("group_blocking", false);
recv.getInternalVariables().setInternalVariable("group_blocking", true); recv.getInternalVariables().setInternalVariable("group_blocking", false);
recv.getInternalVariables().setInternalVariable("group_blocking", true); recv.getInternalVariables().setInternalVariable("group_blocking", false);