本文整理了Java中org.jruby.Ruby.getThreadService
方法的一些代码示例,展示了Ruby.getThreadService
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Ruby.getThreadService
方法的具体详情如下:
包路径:org.jruby.Ruby
类名称:Ruby
方法名:getThreadService
暂无
代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby
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();
}
代码示例来源:origin: org.jruby/jruby-core
public static RubyThread adopt(IRubyObject recv, Thread t) {
final Ruby runtime = recv.getRuntime();
return adoptThread(runtime, runtime.getThreadService(), (RubyClass) recv, t);
}
代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby
public void run() {
nativeThread = Thread.currentThread();
try {
runnable.run();
} finally {
rubyThread.getRuntime().getThreadService().dissociateThread(future);
nativeThread = null;
}
}
});
代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby
@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();
}
}
代码示例来源:origin: com.squareup.rack/rack-servlet
/**
* Creates a byte array Iterator backed by the given Ruby Enumerable.
*
* @param body the backing Enumerable.
*/
public JRubyRackBodyIterator(IRubyObject body) {
this.body = body;
this.threadContext = body.getRuntime().getThreadService().getCurrentContext();
this.enumerator = (RubyEnumerator) body.callMethod(threadContext, "to_enum");
}
代码示例来源:origin: org.jruby/jruby-complete
@JRubyMethod(meta = true)
public static RubyArray list(IRubyObject recv) {
Ruby runtime = recv.getRuntime();
RubyThread[] activeThreads = runtime.getThreadService().getActiveRubyThreads();
return RubyArray.newArrayMayCopy(runtime, activeThreads);
}
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby
@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;
}
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby
private static RubyThread adoptThread(final IRubyObject recv, Thread t, Block block) {
final Ruby runtime = recv.getRuntime();
final RubyThread rubyThread = new RubyThread(runtime, (RubyClass) recv);
rubyThread.threadImpl = new NativeThread(rubyThread, t);
ThreadContext context = runtime.getThreadService().registerNewThread(rubyThread);
runtime.getThreadService().associateThread(t, rubyThread);
context.preAdoptThread();
// set to default thread group
runtime.getDefaultThreadGroup().addDirectly(rubyThread);
return rubyThread;
}
代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby
@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;
}
代码示例来源:origin: org.jruby/jruby-complete
@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);
}
代码示例来源:origin: asciidoctor/asciidoctorj
public void setRubyProperty(String propertyName, IRubyObject arg) {
ThreadContext threadContext = runtime.getThreadService().getCurrentContext();
if (propertyName.startsWith("@")) {
rubyNode.getInstanceVariables().setInstanceVariable(propertyName, arg);
} else {
if (arg == null) {
rubyNode.callMethod(threadContext, propertyName + "=", runtime.getNil());
} else {
rubyNode.callMethod(threadContext, propertyName + "=", arg);
}
}
}
代码示例来源:origin: org.asciidoctor/asciidoctorj
public void setRubyProperty(String propertyName, IRubyObject arg) {
ThreadContext threadContext = runtime.getThreadService().getCurrentContext();
if (propertyName.startsWith("@")) {
rubyNode.getInstanceVariables().setInstanceVariable(propertyName, arg);
} else {
if (arg == null) {
rubyNode.callMethod(threadContext, propertyName + "=", runtime.getNil());
} else {
rubyNode.callMethod(threadContext, propertyName + "=", arg);
}
}
}
代码示例来源:origin: org.jruby/jruby-core
@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);
}
代码示例来源:origin: org.jruby/jruby-complete
@JRubyMethod(meta = true)
public static IRubyObject exit(IRubyObject receiver, Block block) {
RubyThread rubyThread = receiver.getRuntime().getThreadService().getCurrentContext().getThread();
return rubyThread.kill();
}
代码示例来源:origin: org.jruby/jruby-core
@JRubyMethod(meta = true)
public static IRubyObject exit(IRubyObject receiver, Block block) {
RubyThread rubyThread = receiver.getRuntime().getThreadService().getCurrentContext().getThread();
return rubyThread.kill();
}
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby
@JRubyMethod(name = "critical", meta = true, compat = CompatVersion.RUBY1_8)
public static IRubyObject critical(IRubyObject receiver) {
return receiver.getRuntime().newBoolean(receiver.getRuntime().getThreadService().getCritical());
}
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby
@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();
}
代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby
@JRubyMethod(name = "list", meta = true)
public static RubyArray list(IRubyObject recv) {
RubyThread[] activeThreads = recv.getRuntime().getThreadService().getActiveRubyThreads();
return recv.getRuntime().newArrayNoCopy(activeThreads);
}
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby
@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);
}
}
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby
@JRubyMethod(name = {"kill", "exit", "terminate"})
public IRubyObject kill() {
// need to reexamine this
RubyThread currentThread = getRuntime().getCurrentContext().getThread();
// If the killee thread is the same as the killer thread, just die
if (currentThread == this) throwThreadKill();
debug(this, "trying to kill");
currentThread.pollThreadEvents();
getRuntime().getThreadService().deliverEvent(new ThreadService.Event(currentThread, this, ThreadService.Event.Type.KILL));
debug(this, "succeeded with kill");
return this;
}
内容来源于网络,如有侵权,请联系作者删除!