@JRubyMethod(name = "pass", meta = true) public static IRubyObject pass(IRubyObject recv) { Ruby runtime = recv.getRuntime(); ThreadService ts = runtime.getThreadService(); boolean critical = ts.getCritical(); ts.setCritical(false); Thread.yield(); ts.setCritical(critical); return recv.getRuntime().getNil(); }
@JRubyMethod(name = "pass", meta = true) public static IRubyObject pass(IRubyObject recv) { Ruby runtime = recv.getRuntime(); ThreadService ts = runtime.getThreadService(); boolean critical = ts.getCritical(); ts.setCritical(false); Thread.yield(); ts.setCritical(critical); return recv.getRuntime().getNil(); }
@JRubyMethod(name = "exclusive", meta = true, compat = CompatVersion.RUBY1_8) public static IRubyObject exclusive(ThreadContext context, IRubyObject receiver, Block block) { ThreadService service = context.runtime.getThreadService(); boolean old = service.getCritical(); try { service.setCritical(true); return block.yield(receiver.getRuntime().getCurrentContext(), (IRubyObject) null); } finally { service.setCritical(old); } }
@JRubyMethod(name = "exclusive", meta = true, compat = CompatVersion.RUBY1_8) public static IRubyObject exclusive(ThreadContext context, IRubyObject receiver, Block block) { ThreadService service = context.runtime.getThreadService(); boolean old = service.getCritical(); try { service.setCritical(true); return block.yield(receiver.getRuntime().getCurrentContext(), (IRubyObject) null); } finally { service.setCritical(old); } }
@JRubyMethod(name = "critical=", required = 1, meta = true, compat = CompatVersion.RUBY1_8) public static IRubyObject critical_set(IRubyObject receiver, IRubyObject value) { receiver.getRuntime().getThreadService().setCritical(value.isTrue()); return value; }
@JRubyMethod(name = "critical=", required = 1, meta = true, compat = CompatVersion.RUBY1_8) public static IRubyObject critical_set(IRubyObject receiver, IRubyObject value) { receiver.getRuntime().getThreadService().setCritical(value.isTrue()); return value; }
@JRubyMethod(meta = true) public static IRubyObject exit(IRubyObject receiver, Block block) { RubyThread rubyThread = receiver.getRuntime().getThreadService().getCurrentContext().getThread(); synchronized (rubyThread) { rubyThread.status.set(Status.ABORTING); // FIXME: This was not checking for non-null before, but maybe it should rubyThread.mail.set(null); receiver.getRuntime().getThreadService().setCritical(false); throw new ThreadKill(); } }
@JRubyMethod(meta = true) public static IRubyObject exit(IRubyObject receiver, Block block) { RubyThread rubyThread = receiver.getRuntime().getThreadService().getCurrentContext().getThread(); synchronized (rubyThread) { rubyThread.status.set(Status.ABORTING); // FIXME: This was not checking for non-null before, but maybe it should rubyThread.mail.set(null); receiver.getRuntime().getThreadService().setCritical(false); throw new ThreadKill(); } }
@JRubyMethod(name = "stop", meta = true) public static IRubyObject stop(ThreadContext context, IRubyObject receiver) { RubyThread rubyThread = context.getThread(); synchronized (rubyThread) { rubyThread.checkMail(context); try { // attempt to decriticalize all if we're the critical thread receiver.getRuntime().getThreadService().setCritical(false); rubyThread.status.set(Status.SLEEP); rubyThread.wait(); } catch (InterruptedException ie) { rubyThread.checkMail(context); rubyThread.status.set(Status.RUN); } } return receiver.getRuntime().getNil(); }
@JRubyMethod(name = "stop", meta = true) public static IRubyObject stop(ThreadContext context, IRubyObject receiver) { RubyThread rubyThread = context.getThread(); synchronized (rubyThread) { rubyThread.checkMail(context); try { // attempt to decriticalize all if we're the critical thread receiver.getRuntime().getThreadService().setCritical(false); rubyThread.status.set(Status.SLEEP); rubyThread.wait(); } catch (InterruptedException ie) { rubyThread.checkMail(context); rubyThread.status.set(Status.RUN); } } return receiver.getRuntime().getNil(); }
rubyThread.exceptionRaised(t); } finally { runtime.getThreadService().setCritical(false); rubyThread.dispose();
rubyThread.exceptionRaised(t); } finally { runtime.getThreadService().setCritical(false); rubyThread.dispose();