Created
April 12, 2009 01:36
-
-
Save jashkenas/93814 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Spin up a new Ruby VM, start Ruby-Processing in it. | |
private void spinUp(String command, String path) { | |
final RubyInstanceConfig config = new RubyInstanceConfig() {{ | |
setLoader(this.getClass().getClassLoader()); | |
}}; | |
if (_ruby != null) _ruby.tearDown(); | |
_ruby = Ruby.newInstance(config); | |
_ruby.evalScriptlet("RP5_EMBEDDED = true; ARGV[0] = '" + path + "'; require 'ruby-processing/lib/ruby-processing/runners/" + command + ".rb'"); | |
} | |
// Spin down the current running Ruby VM. | |
private void spinDown() { | |
_ruby.evalScriptlet("$app.close"); | |
// TODO: Seems to leak memory ... System.gc() doesn't help... | |
_ruby.tearDown(); | |
_ruby = null; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment