Multiple instances of Ruby interpreter in my C++ code?


(Thorsten Scheuermann) #1

Hi,

I’m new to Ruby and am currently trying to embed Ruby in a C++ program. It
is pretty straightforward and I’ve already had some success with that.
However, what I really want is to have several independent instances of the
interpreter running. Lua for example makes this easy by encapsulating the
interpreter state in a C struct, but I didn’t see that facility in Ruby. Is
there any way to accomplish this?

-Thorsten Scheuermann


(Sean Middleditch) #2

Ruby makes use of a lot of global values - there is no way of doing this
in Ruby currently.

What reason do you have for wanting multiple instances? There may be
another way of accomplishing your goal(s).

···

On Mon, 2002-06-10 at 09:42, Thorsten Scheuermann wrote:

Hi,

I’m new to Ruby and am currently trying to embed Ruby in a C++ program. It
is pretty straightforward and I’ve already had some success with that.
However, what I really want is to have several independent instances of the
interpreter running. Lua for example makes this easy by encapsulating the
interpreter state in a C struct, but I didn’t see that facility in Ruby. Is
there any way to accomplish this?

-Thorsten Scheuermann


(Sean Chittenden) #3

I’m new to Ruby and am currently trying to embed Ruby in a C++
program. It is pretty straightforward and I’ve already had some
success with that. However, what I really want is to have several
independent instances of the interpreter running. Lua for example
makes this easy by encapsulating the interpreter state in a C
struct, but I didn’t see that facility in Ruby. Is there any way
to accomplish this?

Ruby makes use of a lot of global values - there is no way of doing
this in Ruby currently.

What reason do you have for wanting multiple instances? There may
be another way of accomplishing your goal(s).

Same problem, different application domain: Apache 2.0. Inorder for
mod_ruby to support the Threaded MPM, there must be support for
multiple interpreters in the same process. Right now mod_ruby only
supports the prefork MPM.

Are there any plans for locking down the use of globals? Would it be
possible to create a struct of Globals and push the struct onto a
linked list of interpreter states?

-sc

···


Sean Chittenden