@JRubyMethod(name = "priority=", required = 1) public IRubyObject priority_set(IRubyObject priority) { // FIXME: This should probably do some translation from Ruby priority levels to Java priority // levels (until we have green threads) int iPriority = RubyNumeric.fix2int(priority); if (iPriority < Thread.MIN_PRIORITY) { iPriority = Thread.MIN_PRIORITY; } else if (iPriority > Thread.MAX_PRIORITY) { iPriority = Thread.MAX_PRIORITY; } if (threadImpl.isAlive()) { threadImpl.setPriority(iPriority); } return RubyFixnum.newFixnum(getRuntime(), iPriority); }
@JRubyMethod(name = "priority=", required = 1) public IRubyObject priority_set(IRubyObject priority) { int iPriority = RubyNumeric.fix2int(priority); if (iPriority < RUBY_MIN_THREAD_PRIORITY) { iPriority = RUBY_MIN_THREAD_PRIORITY; } else if (iPriority > RUBY_MAX_THREAD_PRIORITY) { iPriority = RUBY_MAX_THREAD_PRIORITY; } if (threadImpl.isAlive()) { int jPriority = rubyPriorityToJavaPriority(iPriority); if (jPriority < Thread.MIN_PRIORITY) { jPriority = Thread.MIN_PRIORITY; } else if (jPriority > Thread.MAX_PRIORITY) { jPriority = Thread.MAX_PRIORITY; } threadImpl.setPriority(jPriority); } return RubyFixnum.newFixnum(getRuntime(), iPriority); }
@JRubyMethod(name = "size", meta = true, visibility = PUBLIC) public static IRubyObject size(ThreadContext context, IRubyObject recv) { return RubyFixnum.newFixnum( context.getRuntime(), Factory.getInstance().sizeOf(NativeType.POINTER)); }
@JRubyMethod(name = "priority") public RubyFixnum priority() { return RubyFixnum.newFixnum(getRuntime(), threadImpl.getPriority()); }