public String dumpThreads(Gather gather) { Ruby ruby = this.ruby.get(); RubyThread[] thrs = ruby.getThreadService().getActiveRubyThreads(); StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); pw.println("All threads known to Ruby instance " + ruby.hashCode()); pw.println(); for (RubyThread th : thrs) { dumpThread(ruby, th, gather, pw); } return sw.toString(); }
public String dumpThreads(Gather gather) { Ruby ruby = this.ruby.get(); RubyThread[] thrs = ruby.getThreadService().getActiveRubyThreads(); StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); pw.println("All threads known to Ruby instance " + ruby.hashCode()); pw.println(); for (RubyThread th : thrs) { dumpThread(ruby, th, gather, pw); } return sw.toString(); }
/** * * Dump all the threads that are known to ruby. We first discover any running * threads and then raise an exception in each thread adding the current thread * and it's context to the backtrace. * * @param gather The level of backtrace that get's raised in each thread * @return [String] A string represnetation of the threds that have been dumped with included backtrace. */ public String dumpThreads(Gather gather) { Ruby ruby = this.ruby.get(); RubyThread[] thrs = ruby.getThreadService().getActiveRubyThreads(); StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); pw.println("All threads known to Ruby instance " + ruby.hashCode()); pw.println(); for (RubyThread th : thrs) { dumpThread(ruby, th, gather, pw); } return sw.toString(); }
/** * * Dump all the threads that are known to ruby. We first discover any running * threads and then raise an exception in each thread adding the current thread * and it's context to the backtrace. * * @param gather The level of backtrace that get's raised in each thread * @return [String] A string represnetation of the threds that have been dumped with included backtrace. */ public String dumpThreads(Gather gather) { Ruby ruby = this.ruby.get(); RubyThread[] thrs = ruby.getThreadService().getActiveRubyThreads(); StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); pw.println("All threads known to Ruby instance " + ruby.hashCode()); pw.println(); for (RubyThread th : thrs) { dumpThread(ruby, th, gather, pw); } return sw.toString(); }
@JRubyMethod(meta = true) public static IRubyObject stop(ThreadContext context, IRubyObject receiver) { RubyThread rubyThread = context.getThread(); if (context.runtime.getThreadService().getActiveRubyThreads().length == 1) { throw context.runtime.newThreadError("stopping only thread\n\tnote: use sleep to stop forever"); } synchronized (rubyThread) { rubyThread.pollThreadEvents(context); Status oldStatus = rubyThread.status.get(); try { rubyThread.status.set(Status.SLEEP); rubyThread.wait(); } catch (InterruptedException ie) { } finally { rubyThread.pollThreadEvents(context); rubyThread.status.set(oldStatus); } } return context.nil; }
@JRubyMethod(meta = true) public static RubyArray list(IRubyObject recv) { Ruby runtime = recv.getRuntime(); RubyThread[] activeThreads = runtime.getThreadService().getActiveRubyThreads(); return RubyArray.newArrayMayCopy(runtime, activeThreads); }
@JRubyMethod(meta = true) public static IRubyObject stop(ThreadContext context, IRubyObject receiver) { RubyThread rubyThread = context.getThread(); if (context.runtime.getThreadService().getActiveRubyThreads().length == 1) { throw context.runtime.newThreadError("stopping only thread\n\tnote: use sleep to stop forever"); } synchronized (rubyThread) { rubyThread.pollThreadEvents(context); Status oldStatus = rubyThread.status.get(); try { rubyThread.status.set(Status.SLEEP); rubyThread.wait(); } catch (InterruptedException ie) { } finally { rubyThread.pollThreadEvents(context); rubyThread.status.set(oldStatus); } } return context.nil; }
private void forceStopRubyThreads() { // if the container is disposed already, bail out if (data.container == null) return; // try to kill all threads once if (!data.forcedHalt) { data.forcedHalt = true; } else { return; } if (data.runtime != null) { RubyThread[] threads = data.runtime.getThreadService().getActiveRubyThreads(); for (int i = 0; i < threads.length; i++) { try { threads[i].kill(); } catch (ThreadKill e) { } } data.runtime.tearDown(); } }
@JRubyMethod(meta = true) public static RubyArray list(IRubyObject recv) { Ruby runtime = recv.getRuntime(); RubyThread[] activeThreads = runtime.getThreadService().getActiveRubyThreads(); return RubyArray.newArrayMayCopy(runtime, activeThreads); }
@JRubyMethod(name = "list", meta = true) public static RubyArray list(IRubyObject recv) { RubyThread[] activeThreads = recv.getRuntime().getThreadService().getActiveRubyThreads(); return recv.getRuntime().newArrayNoCopy(activeThreads); }
@JRubyMethod(name = "list", meta = true) public static RubyArray list(IRubyObject recv) { RubyThread[] activeThreads = recv.getRuntime().getThreadService().getActiveRubyThreads(); return recv.getRuntime().newArrayNoCopy(activeThreads); }