On Tue, 16 Oct 2001, Emiliano wrote:
> Yukihiro Matsumoto wrote:
> > |- I've been told (totally unverified) that ruby isn't thread-safe, and
> > |  that making it thread-safe would be hard. How much truth is there to
> > |  this?
> > It's not thread-safe.  Some tried the way that everything related in
> > Ruby in one native thread, then other threads send request via queue.
> OK, so that'd be kind of a 'ruby server' thread. How about separate
> scripts running in separate threads?

Ruby has its own little internal thread system that works by making the
evaluator cooperatively threading with itself; C-level libraries that do
I/O or long-lasting operations are encouraged to participate. At the Ruby
level you have Threads and Continuations provided by that underlying
system.

Which means you can do a 1-to-1 mapping from native threads to Ruby
threads if you want. It also does not need to be a 1-to-1 mapping (it was
just an example).

However you should not put critical scripts in the same Process as
untrusted scripts, because the latter can hog resources at any level of
thread-jailing ($SAFE) just by using large Strings, Arrays, Hashes,
Bignums, and difficult Regexps.

________________________________________________________________
Mathieu Bouchard                   http://hostname.2y.net/~matju