MenTaLguY
12/14/2007 12:29:00 AM
On Fri, 14 Dec 2007 08:25:04 +0900, "Just Another Victim of the Ambient Morality" <ihatespam@hotmail.com> wrote:
> If Ruby 1.9 will use system threads, what will happen to the green threads?
Ruby will no longer have green threads, as such.
> What will happen to libraries that require green threads, like generator.rb?
> Will they end up using system threads?
They'll be using coroutines (fibers) rather than threads, which are a
lighter-weight alternative to green threads. Fibers will also be used
to provide external iterators.
> If Ruby is using system threads, does that mean Ruby will be thread
> safe? That is, will we be able to call into an embedded Ruby interpreter
> from multiple threads?
Not at this time. The main difficulty is that the Ruby interpreter requires
any thread calling into it to have certain special setup done at thread
creation time (which Ruby performs when creating its own threads, but won't
have been done for any application-created threads except for the one that
initialized the Ruby interpreter).
Also, initially, there will be a single large mutex around the Ruby
interpreter, preventing any of the Ruby system threads from running
concurrently (and also strictly serializing their memory effects). Over
time it may be relaxed, however, as synchronization of the interpreter
becomes more fine-grained.
> Matz's most "regretting" behaviour of Ruby is that block variables are
> local to the block. Will this be changed in Ruby 1.9?
I'm a little fuzzy on what happens to variables which are simply
implicitly declared. However, block arguments will always be
block-local in 1.9, and there is additional syntax for explicitly
declaring a variable to be block-local (block-local variable names
follow a semicolon in the block argument list).
> Finally, if Ruby will now be compiled into bytecode, will we be able
> to run the bytecode without the Ruby source?
Possibly. JRuby has (experimental) support for YARV-compiled scripts,
with -Y compiling a script and -y running a compiled script. I don't
think ruby 1.9 offers a commandline option to do it at this time, but
it seems a likely eventual addition.
> Will Ruby be able to do this in an embedded application?
Assuming support for running bytecode directly in the final 1.9, it
would be trivial.
-mental