本文整理了Java中org.jruby.Ruby.getThread
方法的一些代码示例,展示了Ruby.getThread
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Ruby.getThread
方法的具体详情如下:
包路径:org.jruby.Ruby
类名称:Ruby
方法名:getThread
[英]Get the thread-local runtime for the current thread, or null if unset.
[中]获取当前线程的线程本地运行时,如果未设置,则为null。
代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby
private SoftReference adoptCurrentThread() {
Thread current = Thread.currentThread();
RubyThread.adopt(runtime.getThread(), current);
return (SoftReference) localContext.get();
}
代码示例来源:origin: org.jruby/jruby-complete
public static RubyThread adopt(Ruby runtime, ThreadService service, Thread thread) {
return adoptThread(runtime, service, runtime.getThread(), thread);
}
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby
private SoftReference adoptCurrentThread() {
Thread current = Thread.currentThread();
RubyThread.adopt(runtime.getThread(), current);
return (SoftReference) localContext.get();
}
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby
public static IRubyObject newThread(Ruby runtime, long fn, IRubyObject args_ary) {
RubyProc proc = (RubyProc) newProc(runtime, fn);
IRubyObject[] args = (args_ary instanceof RubyArray) ? ((RubyArray)args_ary).toJavaArray() : new IRubyObject[] {args_ary};
return RubyThread.newInstance(runtime.getThread(), args, proc.getBlock());
}
代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby
public static IRubyObject newThread(Ruby runtime, long fn, IRubyObject args_ary) {
RubyProc proc = (RubyProc) newProc(runtime, fn);
IRubyObject[] args = (args_ary instanceof RubyArray) ? ((RubyArray)args_ary).toJavaArray() : new IRubyObject[] {args_ary};
return RubyThread.newInstance(runtime.getThread(), args, proc.getBlock());
}
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby
public void load(final Ruby runtime, boolean wrap) throws IOException {
runtime.getThread().defineAnnotatedMethods(ThreadMethods.class);
Mutex.setup(runtime);
ConditionVariable.setup(runtime);
Queue.setup(runtime);
SizedQueue.setup(runtime);
}
}
代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby
public void load(final Ruby runtime, boolean wrap) throws IOException {
runtime.getThread().defineAnnotatedMethods(ThreadMethods.class);
Mutex.setup(runtime);
ConditionVariable.setup(runtime);
Queue.setup(runtime);
SizedQueue.setup(runtime);
}
}
代码示例来源:origin: org.jruby/jruby-complete
private static Mutex getMutexForThreadExclusive(ThreadContext context, RubyClass recv) {
Mutex mutex = (Mutex) recv.getConstantNoConstMissing(MUTEX_FOR_THREAD_EXCLUSIVE, false, false);
if (mutex != null) return mutex;
synchronized (recv) {
mutex = (Mutex) recv.getConstantNoConstMissing(MUTEX_FOR_THREAD_EXCLUSIVE, false, false);
if (mutex == null) {
mutex = Mutex.newInstance(context, context.runtime.getThread().getClass("Mutex"), NULL_ARRAY, Block.NULL_BLOCK);
recv.setConstant(MUTEX_FOR_THREAD_EXCLUSIVE, mutex, true);
}
return mutex;
}
}
代码示例来源:origin: org.jruby/jruby-core
private static Mutex getMutexForThreadExclusive(ThreadContext context, RubyClass recv) {
Mutex mutex = (Mutex) recv.getConstantNoConstMissing(MUTEX_FOR_THREAD_EXCLUSIVE, false, false);
if (mutex != null) return mutex;
synchronized (recv) {
mutex = (Mutex) recv.getConstantNoConstMissing(MUTEX_FOR_THREAD_EXCLUSIVE, false, false);
if (mutex == null) {
mutex = Mutex.newInstance(context, context.runtime.getThread().getClass("Mutex"), NULL_ARRAY, Block.NULL_BLOCK);
recv.setConstant(MUTEX_FOR_THREAD_EXCLUSIVE, mutex, true);
}
return mutex;
}
}
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby
@JRubyMethod(required = 1, meta = true)
public static IRubyObject kill(IRubyObject receiver, IRubyObject rubyThread, Block block) {
if (!(rubyThread instanceof RubyThread)) throw receiver.getRuntime().newTypeError(rubyThread, receiver.getRuntime().getThread());
return ((RubyThread)rubyThread).kill();
}
代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby
@JRubyMethod(required = 1, meta = true)
public static IRubyObject kill(IRubyObject receiver, IRubyObject rubyThread, Block block) {
if (!(rubyThread instanceof RubyThread)) throw receiver.getRuntime().newTypeError(rubyThread, receiver.getRuntime().getThread());
return ((RubyThread)rubyThread).kill();
}
代码示例来源:origin: org.jruby/jruby-complete
@JRubyMethod(required = 1, meta = true)
public static IRubyObject kill(IRubyObject receiver, IRubyObject rubyThread, Block block) {
if (!(rubyThread instanceof RubyThread)) throw receiver.getRuntime().newTypeError(rubyThread, receiver.getRuntime().getThread());
return ((RubyThread)rubyThread).kill();
}
代码示例来源:origin: org.jruby/jruby-core
@JRubyMethod(required = 1, meta = true)
public static IRubyObject kill(IRubyObject receiver, IRubyObject rubyThread, Block block) {
if (!(rubyThread instanceof RubyThread)) throw receiver.getRuntime().newTypeError(rubyThread, receiver.getRuntime().getThread());
return ((RubyThread)rubyThread).kill();
}
代码示例来源:origin: org.jruby/jruby-core
public static void setup(Ruby runtime) {
RubyClass cSizedQueue = runtime.getThread().defineClassUnder("SizedQueue", runtime.getClass("Queue"), new ObjectAllocator() {
public IRubyObject allocate(Ruby runtime, RubyClass klass) {
return new SizedQueue(runtime, klass);
}
});
cSizedQueue.setReifiedClass(SizedQueue.class);
cSizedQueue.defineAnnotatedMethods(SizedQueue.class);
runtime.getObject().setConstant("SizedQueue", cSizedQueue);
}
代码示例来源:origin: org.jruby/jruby-complete
public static void setup(Ruby runtime) {
RubyClass cSizedQueue = runtime.getThread().defineClassUnder("SizedQueue", runtime.getClass("Queue"), new ObjectAllocator() {
public IRubyObject allocate(Ruby runtime, RubyClass klass) {
return new SizedQueue(runtime, klass);
}
});
cSizedQueue.setReifiedClass(SizedQueue.class);
cSizedQueue.defineAnnotatedMethods(SizedQueue.class);
runtime.getObject().setConstant("SizedQueue", cSizedQueue);
}
代码示例来源:origin: org.jruby/jruby-complete
public static void setup(Ruby runtime) {
RubyClass cMutex = runtime.getThread().defineClassUnder("Mutex", runtime.getObject(), new ObjectAllocator() {
public IRubyObject allocate(Ruby runtime, RubyClass klass) {
return new Mutex(runtime, klass);
}
});
cMutex.setReifiedClass(Mutex.class);
cMutex.defineAnnotatedMethods(Mutex.class);
runtime.getObject().setConstant("Mutex", cMutex);
}
代码示例来源:origin: org.jruby/jruby-core
public static void setup(Ruby runtime) {
RubyClass cMutex = runtime.getThread().defineClassUnder("Mutex", runtime.getObject(), new ObjectAllocator() {
public IRubyObject allocate(Ruby runtime, RubyClass klass) {
return new Mutex(runtime, klass);
}
});
cMutex.setReifiedClass(Mutex.class);
cMutex.defineAnnotatedMethods(Mutex.class);
runtime.getObject().setConstant("Mutex", cMutex);
}
代码示例来源:origin: org.jruby/jruby-complete
public static void setup(Ruby runtime) {
RubyClass cConditionVariable = runtime.getThread().defineClassUnder("ConditionVariable", runtime.getObject(), new ObjectAllocator() {
public IRubyObject allocate(Ruby runtime, RubyClass klass) {
return new ConditionVariable(runtime, klass);
}
});
cConditionVariable.undefineMethod("initialize_copy");
cConditionVariable.setReifiedClass(ConditionVariable.class);
cConditionVariable.defineAnnotatedMethods(ConditionVariable.class);
runtime.getObject().setConstant("ConditionVariable", cConditionVariable);
}
代码示例来源:origin: org.jruby/jruby-core
public static void setup(Ruby runtime) {
RubyClass cConditionVariable = runtime.getThread().defineClassUnder("ConditionVariable", runtime.getObject(), new ObjectAllocator() {
public IRubyObject allocate(Ruby runtime, RubyClass klass) {
return new ConditionVariable(runtime, klass);
}
});
cConditionVariable.undefineMethod("initialize_copy");
cConditionVariable.setReifiedClass(ConditionVariable.class);
cConditionVariable.defineAnnotatedMethods(ConditionVariable.class);
runtime.getObject().setConstant("ConditionVariable", cConditionVariable);
}
代码示例来源:origin: org.jruby/jruby-complete
public static void setup(Ruby runtime) {
RubyClass cQueue = runtime.getThread().defineClassUnder("Queue", runtime.getObject(), new ObjectAllocator() {
public IRubyObject allocate(Ruby runtime, RubyClass klass) {
return new Queue(runtime, klass);
}
});
cQueue.undefineMethod("initialize_copy");
cQueue.setReifiedClass(Queue.class);
cQueue.defineAnnotatedMethods(Queue.class);
runtime.getObject().setConstant("Queue", cQueue);
RubyClass cClosedQueueError = cQueue.defineClassUnder("ClosedQueueError", runtime.getStopIteration(), runtime.getStopIteration().getAllocator());
runtime.getObject().setConstant("ClosedQueueError", cClosedQueueError);
}
内容来源于网络,如有侵权,请联系作者删除!