public static RubyThread mainThread(IRubyObject receiver) { return receiver.getRuntime().getThreadService().getMainThread(); }
public static RubyThread mainThread(IRubyObject receiver) { return receiver.getRuntime().getThreadService().getMainThread(); }
public static RubyThread mainThread(IRubyObject receiver) { return receiver.getRuntime().getThreadService().getMainThread(); }
public static RubyThread mainThread(IRubyObject receiver) { return receiver.getRuntime().getThreadService().getMainThread(); }
@JRubyMethod(meta = true) public static RubyThread main(IRubyObject recv) { return recv.getRuntime().getThreadService().getMainThread(); }
@JRubyMethod(meta = true) public static RubyThread main(IRubyObject recv) { return recv.getRuntime().getThreadService().getMainThread(); }
@JRubyMethod(name = "main", meta = true) public static RubyThread main(IRubyObject recv) { return recv.getRuntime().getThreadService().getMainThread(); }
@JRubyMethod(name = "main", meta = true) public static RubyThread main(IRubyObject recv) { return recv.getRuntime().getThreadService().getMainThread(); }
@JRubyMethod(name = {"kill", "exit", "terminate"}) public IRubyObject kill() { Ruby runtime = getRuntime(); // need to reexamine this RubyThread currentThread = runtime.getCurrentContext().getThread(); if (currentThread == runtime.getThreadService().getMainThread()) { // rb_exit to hard exit process...not quite right for us } status.set(Status.ABORTING); return genericKill(runtime, currentThread); }
@JRubyMethod(name = {"kill", "exit", "terminate"}) public IRubyObject kill() { Ruby runtime = getRuntime(); // need to reexamine this RubyThread currentThread = runtime.getCurrentContext().getThread(); if (currentThread == runtime.getThreadService().getMainThread()) { // rb_exit to hard exit process...not quite right for us } status.set(Status.ABORTING); return genericKill(runtime, currentThread); }
/** * For handling all non-Ruby exceptions bubbling out of threads * @param exception */ @SuppressWarnings("deprecation") public void exceptionRaised(Throwable exception) { if (exception instanceof RaiseException) { exceptionRaised((RaiseException)exception); return; } assert isCurrent(); Ruby runtime = getRuntime(); if (abortOnException(runtime) && exception instanceof Error) { // re-propagate on main thread runtime.getThreadService().getMainThread().getNativeThread().stop(exception); } else { // just rethrow on this thread, let system handlers report it Helpers.throwException(exception); } }
/** * For handling all non-Ruby exceptions bubbling out of threads * @param exception */ @SuppressWarnings("deprecation") public void exceptionRaised(Throwable exception) { if (exception instanceof RaiseException) { exceptionRaised((RaiseException)exception); return; } assert isCurrent(); Ruby runtime = getRuntime(); if (abortOnException(runtime) && exception instanceof Error) { // re-propagate on main thread runtime.getThreadService().getMainThread().getNativeThread().stop(exception); } else { // just rethrow on this thread, let system handlers report it Helpers.throwException(exception); } }
if (currentThread == runtime.getThreadService().getMainThread()) { throw uncaught.uncaughtThrow(runtime, message, tag); } else {
public void handle(Signal signal) { ThreadContext context = runtime.getCurrentContext(); try { if (block != null) { block.callMethod(context, "call"); } else { blockCallback.call(context, new IRubyObject[0], Block.NULL_BLOCK); } } catch(RaiseException e) { try { runtime.getThread().callMethod(context, "main") .callMethod(context, "raise", e.getException()); } catch(Exception ignored) {} } catch (MainExitException mee) { runtime.getThreadService().getMainThread().kill(); } finally { Signal.handle(new Signal(this.signal), this); } } }
public void handle(Signal signal) { ThreadContext context = runtime.getCurrentContext(); try { if (block != null) { block.callMethod(context, "call"); } else { blockCallback.call(context, new IRubyObject[0], Block.NULL_BLOCK); } } catch(RaiseException e) { try { runtime.getThread().callMethod(context, "main") .callMethod(context, "raise", e.getException()); } catch(Exception ignored) {} } catch (MainExitException mee) { runtime.getThreadService().getMainThread().kill(); } finally { Signal.handle(new Signal(this.signal), this); } } }
public void exceptionRaised(RaiseException exception) { assert isCurrent(); RubyException rubyException = exception.getException(); Ruby runtime = rubyException.getRuntime(); if (runtime.getSystemExit().isInstance(rubyException)) { runtime.getThreadService().getMainThread().raise(new IRubyObject[] {rubyException}, Block.NULL_BLOCK); } else if (abortOnException(runtime)) { RubyException systemExit; if (!runtime.is1_9()) { runtime.printError(rubyException); String message = rubyException.message.convertToString().toString(); systemExit = RubySystemExit.newInstance(runtime, 1, message); systemExit.set_backtrace(rubyException.backtrace()); } else { systemExit = rubyException; } runtime.getThreadService().getMainThread().raise(new IRubyObject[] {systemExit}, Block.NULL_BLOCK); return; } else if (runtime.getDebug().isTrue()) { runtime.printError(exception.getException()); } exitingException = exception; }
public void exceptionRaised(RaiseException exception) { assert isCurrent(); RubyException rubyException = exception.getException(); Ruby runtime = rubyException.getRuntime(); if (runtime.getSystemExit().isInstance(rubyException)) { runtime.getThreadService().getMainThread().raise(new IRubyObject[] {rubyException}, Block.NULL_BLOCK); } else if (abortOnException(runtime)) { RubyException systemExit; if (!runtime.is1_9()) { runtime.printError(rubyException); String message = rubyException.message.convertToString().toString(); systemExit = RubySystemExit.newInstance(runtime, 1, message); systemExit.set_backtrace(rubyException.backtrace()); } else { systemExit = rubyException; } runtime.getThreadService().getMainThread().raise(new IRubyObject[] {systemExit}, Block.NULL_BLOCK); return; } else if (runtime.getDebug().isTrue()) { runtime.printError(exception.getException()); } exitingException = exception; }
public static void initiateNonLocalReturn(ThreadContext context, IRScope scope, IRMethod methodToReturnFrom, IRubyObject returnValue) { if (scope instanceof IRClosure) { if (methodToReturnFrom == null) { // SSS FIXME: As Tom correctly pointed out, this is not correct. The example that breaks this code is: // // jruby -X-CIR -e "Thread.new { Proc.new { return }.call }.join" // // This should report a LocalJumpError, not a ThreadError. // // The right fix would involve checking the closure to see who it is associated with. // If it is a thread-body, it would be a ThreadError. If not, it would be a local-jump-error // This requires having access to the block -- same requirement as in handleBreakJump. if (context.getThread() == context.runtime.getThreadService().getMainThread()) { throw IRException.RETURN_LocalJumpError.getException(context.runtime); } else { throw context.runtime.newThreadError("return can't jump across threads"); } } // Cannot return from the call that we have long since exited. if (!context.scopeExistsOnCallStack(methodToReturnFrom.getStaticScope())) { if (isDebug()) LOG.info("in scope: " + scope + ", raising unexpected return local jump error"); throw IRException.RETURN_LocalJumpError.getException(context.runtime); } } // methodtoReturnFrom will not be null for explicit returns from class/module/sclass bodies throw IRReturnJump.create(methodToReturnFrom, returnValue); }
public void handle(Signal signal) { ThreadContext context = runtime.getCurrentContext(); IRubyObject oldExc = runtime.getGlobalVariables().get("$!"); // Save $! try { RubyFixnum signum = runtime.newFixnum(signal.getNumber()); if (block != null) { block.callMethod(context, "call", signum); } else { blockCallback.call(context, new IRubyObject[] {signum}, Block.NULL_BLOCK); } } catch(RaiseException e) { try { runtime.getThread().callMethod(context, "main") .callMethod(context, "raise", e.getException()); } catch(Exception ignored) {} runtime.getGlobalVariables().set("$!", oldExc); // Restore $! } catch (MainExitException mee) { runtime.getThreadService().getMainThread().kill(); } finally { Signal.handle(new Signal(this.signal), this); } } }
public void handle(Signal signal) { ThreadContext context = runtime.getCurrentContext(); IRubyObject oldExc = runtime.getGlobalVariables().get("$!"); // Save $! try { RubyFixnum signum = runtime.newFixnum(signal.getNumber()); if (block != null) { block.callMethod(context, "call", signum); } else { blockCallback.call(context, new IRubyObject[] {signum}, Block.NULL_BLOCK); } } catch(RaiseException e) { try { runtime.getThread().callMethod(context, "main") .callMethod(context, "raise", e.getException()); } catch(Exception ignored) {} runtime.getGlobalVariables().set("$!", oldExc); // Restore $! } catch (MainExitException mee) { runtime.getThreadService().getMainThread().kill(); } finally { Signal.handle(new Signal(this.signal), this); } } }