On Fri, May 04, 2001 at 04:05:04PM +0200, Artur Bergman wrote:
> 01-05-04 12.16, skrev Alan Burlison p� [EMAIL PROTECTED] f�ljande:
> 
> > Dan Sugalski wrote:
> > 
> >> Serializing calls into a non-thread-safe library will often be enough. Not
> >> always, mind, but quite often.
> > 
> > Only if the library has no stored state.
> > 
> > Alan Burlison
> > 
> 
> But that is pretty easy to fix by using thread local storage (like perl does
> for the current perl-interpreter).

Huh?  Unless you know what the stored state is, you can't.  For example
the getpwnam(), getpwuid() have an iterator hidden in the bowels of the
library.  If you don't know what it is, you can't thread-safe that.  Ditto
for, say, rand().  It may have several longwords worth of state hidden
away somewhere, and unless you know what it is -- and also how to inject
that back to the library when it needs it -- you can't thread-safe it.

> It shouldn't me too much of work to make a library thread-safe, it is much
> harder to make it utilize the fact that there are threads.
> 
> Maybe it would be possible to add a option to XS to automaticly add code to
> mutex protect an entire library. (This won't solve the problem with stored
> state, but my belief is it would help in most cases).
> 
> Artur

-- 
$jhi++; # http://www.iki.fi/jhi/
        # There is this special biologist word we use for 'stable'.
        # It is 'dead'. -- Jack Cohen

Reply via email to