Robin -
Keith R. Bennett
On Jan 26, 2013, at 4:07 AM, Robin McKay [email protected] wrote:
Thanks Keith,
Very interesting presentation which I’ve bookmarked.
Thanks. If you’d like the audio of the presentation, the audio and
slideshow are both at
http://www.bbs-software.com/blog/2012/09/04/jruby-presentation-northern-virginia-ruby-user-group/.
Nothing special, but there might be some useful pieces of information.
More below…
def showStuff(stuff)
And then in another thread I would like to be able to do something which
is the same as showStuff(“This is a test”).
I am thinking of a concept a bit like the way ScriptingContainer can
call methods in a script - but all entirely in JRuby.
It sounds like what you’re really looking to do is eval or load, not
require, right? Require will load the file once per Ruby VM lifetime, so
subsequent uses would have no effect.
As I understand it, you want to evaluate an arbitrary chunk of code, and
do it in its own thread. You could do that, but doing that in threads as
you describe is not as effective in isolating the jobs from each other
as would be running each in a ScriptingContainer. Any classes you load
(or, even worse, modify) would be shared by all threads. And there
could be variables that would be shared as well (class variables, static
variables, etc.).
For more protection, you’d want each job to have its own Ruby virtual
machine, not just its own thread. If, on the other hand, you had control
over the types of jobs that were requested, sharing the Ruby VM might
not be a bad thing.