From: Jean-Hugues ROBERT Date: 2002-06-11T01:27:26+09:00 Subject: RE: multiple instances of Ruby interpreter in my C++ code? Hello, At 23:24 10/06/2002 +0900, you wrote: >To be honest, I've never really seen the point of cooperative >multi-tasking. When making the code "thread safe" is not worth the trouble, it becomes handy to revert to cooperative multi-tasking. Not to mention that the code is much easier to debug (race condition bugs are very much the modern equivalent of the old C dangling pointer of the past, in terms of difficulty to debug them, to me). BTW: closures make it much less useful to use preemption, you achieve the same simplicity/readability with them than with threads, often, IMO. About embedding Ruby, I would prefer it to be as easy as it is for other languages, Tcl for example. The more Ruby users, the better I feel ;-) Maybe the multiple instances of Ruby interpreter can be workarounded with load( file, private_flag), where private_flag deals with namespaces... I don't know if there is some equivalent for eval() but I am pretty sure that by enclosing the code inside a "begin"/"end" the local variables are going to be "local" to each "instance". Switching from one ruby "thread" to another is a matter of calling the underlying multi-tasker "yield()" function I guess Conclusion: With cooperative multi-tasking, multiple instances of Ruby interpreter can be "simulated". There are probably some data with "global" scope that need some more handling and that I am overlooking. Yours, Jean-Hugues