本文整理了Java中org.jruby.Ruby.addFinalizer
方法的一些代码示例,展示了Ruby.addFinalizer
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Ruby.addFinalizer
方法的具体详情如下:
包路径:org.jruby.Ruby
类名称:Ruby
方法名:addFinalizer
暂无
代码示例来源:origin: headius/jo
public void load(Ruby runtime, boolean wrap) throws IOException {
RubyModule jo = runtime.defineModule("Jo");
final ExecutorService executor = Executors.newCachedThreadPool(new ThreadFactory() {
public Thread newThread(Runnable r) {
Thread t = new Thread(r);
t.setDaemon(true);
return t;
}
});
jo.setInternalVariable("executor", executor);
RubyClass joFuture = jo.defineClassUnder("Future", runtime.getObject(), ObjectAllocator.NOT_ALLOCATABLE_ALLOCATOR);
RubyClass joChannel = jo.defineClassUnder("Channel", runtime.getObject(), ObjectAllocator.NOT_ALLOCATABLE_ALLOCATOR);
jo.defineAnnotatedMethods(JoMethods.class);
joFuture.defineAnnotatedMethods(JoFuture.class);
joChannel.defineAnnotatedMethods(JoChannel.class);
runtime.addFinalizer(new Finalizable() {
public void finalize() {
executor.shutdown();
}
});
}
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby
/**
* Adds the specified object as a finalizer for this object.
*/
public void addFinalizer(IRubyObject f) {
Finalizer finalizer = (Finalizer)getInternalVariable("__finalizer__");
if (finalizer == null) {
// since this is the first time we're registering a finalizer, we
// must also register this object in ObjectSpace, so that future
// calls to undefine_finalizer, which takes an object ID, can
// locate the object properly. See JRUBY-4839.
long id = getObjectId();
RubyFixnum fixnumId = (RubyFixnum)id();
getRuntime().getObjectSpace().registerObjectId(id, this);
finalizer = new Finalizer(fixnumId);
fastSetInternalVariable("__finalizer__", finalizer);
getRuntime().addFinalizer(finalizer);
}
finalizer.addFinalizer(f);
}
代码示例来源:origin: org.jruby/jruby-complete
/**
* Adds the specified object as a finalizer for this object.
*/
@Override
public void addFinalizer(IRubyObject f) {
Finalizer finalizer = (Finalizer) getInternalVariable("__finalizer__");
if (finalizer == null) {
// since this is the first time we're registering a finalizer, we
// must also register this object in ObjectSpace, so that future
// calls to undefine_finalizer, which takes an object symbol, can
// locate the object properly. See JRUBY-4839.
long id = getObjectId();
IRubyObject fixnumId = id();
getRuntime().getObjectSpace().registerObjectId(id, this);
finalizer = new Finalizer(fixnumId);
setInternalVariable("__finalizer__", finalizer);
getRuntime().addFinalizer(finalizer);
}
finalizer.addFinalizer(f);
}
代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby
/**
* Adds the specified object as a finalizer for this object.
*/
public void addFinalizer(IRubyObject f) {
Finalizer finalizer = (Finalizer)getInternalVariable("__finalizer__");
if (finalizer == null) {
// since this is the first time we're registering a finalizer, we
// must also register this object in ObjectSpace, so that future
// calls to undefine_finalizer, which takes an object ID, can
// locate the object properly. See JRUBY-4839.
long id = getObjectId();
RubyFixnum fixnumId = (RubyFixnum)id();
getRuntime().getObjectSpace().registerObjectId(id, this);
finalizer = new Finalizer(fixnumId);
fastSetInternalVariable("__finalizer__", finalizer);
getRuntime().addFinalizer(finalizer);
}
finalizer.addFinalizer(f);
}
代码示例来源:origin: org.jruby/jruby-core
/**
* Adds the specified object as a finalizer for this object.
*/
@Override
public void addFinalizer(IRubyObject f) {
Finalizer finalizer = (Finalizer) getInternalVariable("__finalizer__");
if (finalizer == null) {
// since this is the first time we're registering a finalizer, we
// must also register this object in ObjectSpace, so that future
// calls to undefine_finalizer, which takes an object symbol, can
// locate the object properly. See JRUBY-4839.
long id = getObjectId();
IRubyObject fixnumId = id();
getRuntime().getObjectSpace().registerObjectId(id, this);
finalizer = new Finalizer(fixnumId);
setInternalVariable("__finalizer__", finalizer);
getRuntime().addFinalizer(finalizer);
}
finalizer.addFinalizer(f);
}
内容来源于网络,如有侵权,请联系作者删除!