From: Sean Middleditch Date: 2002-06-10T23:24:42+09:00 Subject: RE: multiple instances of Ruby interpreter in my C++ code? To be honest, I've never really seen the point of cooperative multi-tasking. Might as well just be a single "task" will callback methods... ~,^ The whole purpose of the Ruby threading model is to not be limited to cooperative multi-tasking. Again, for what you want, given that you seem to require your app be multi-threading, another language may be better for you. Ruby is much more a high-level programming language than it is an embeddable extension language. Lua, TCL (as mentioned by Dossy), and others (including Scriptix) are designed for extending an application, and will be much better suited to your needs than Ruby. On Mon, 2002-06-10 at 10:17, Thorsten Scheuermann wrote: > Well, the threading in the app is cooperative, not preemptive. So if there > was a way to spawn each script in a Ruby thread, and switch to a specific > thread through a C or Ruby call I think I could do it. > > Then I could basically do this: > > while(!done) > { > switch to my ruby thread > for(a while) > run a line of ruby code > yield() > } > > -----Original Message----- > From: Sean Middleditch [mailto:elanthis@awesomeplay.com] > Sent: Monday, June 10, 2002 10:11 AM > To: ruby-talk@ruby-lang.org > Subject: RE: multiple instances of Ruby interpreter in my C++ code? > > > Ew, the threading will be a problem. As mad as some people on the list > may get at me for saying so, in the interest of "the best tool for the > job," Ruby may not be your best bet if your app requires the > multi-threading. > > On the other hand, Ruby itself has great threading support - you may > wish to have your app run in a single OS thread, and let the Ruby > scripts be multi-threaded? > > Otherwise, of the languages I know, Lua would probably work best for > you. > > On Mon, 2002-06-10 at 10:05, Thorsten Scheuermann wrote: > > I wanted to use it in a module for an application to run (currently) very > > simple scripts. The thing is that the app is multithreaded and several > > instances of this module could run concurrently executing different > scripts. > > The scripts right now just look like this: > > > > doSomething(x) > > doSomethingElse(A_CONSTANT) > > ... > > > > They are automatically generated but eventually I will write new ones by > > hand and that's where the flexibility of Ruby would come in handy. the > calls > > that are made in the scripts end up calling wrapped C/C++ functions. > > If I have something like > > script1: x = foo() > > script2: x = bar() > > I don't want the scripts to actually share the variable x. They should be > > visible only in the scope of the particular script. Maybe there's a way of > > wrapping these scripts inside a Ruby module through a preprocessor so that > > they are isolated from each other? > > > > -Thorsten > > > > -----Original Message----- > > From: Sean Middleditch [mailto:elanthis@awesomeplay.com] > > Sent: Monday, June 10, 2002 9:49 AM > > To: ruby-talk@ruby-lang.org > > Subject: Re: multiple instances of Ruby interpreter in my C++ code? > > > > > > 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 > > > > > >