On Sat, 5 May 2001, Alan Burlison wrote:
> Chris Stith wrote:
> > In any case, it may be that the module writer should be held
> > responsible to either declare the underlying library thread-safe
> > and document his module accordingly, or to document his module
> > to say that it is not thread-safe. I realize this means that not
> > all code will ever be able to be thread-safe, but that's where
> > we are now.
>
> That's on onerous responsibility - don't forget, a lot of kind people have
> contributed lots of time and code to wrap external libraries for which they
> are not responsible, and we don't want to make the task any more burdensome
> for them. Lots of these people aren't qualified to make statements about
> the thread safety of the underlying library - especially if they don't have
> source.
It's true there's a bunch of libraries out there that can't be known
to be thread-safe. Perhaps threading the ones we can be sure about
would be enough. After all, you can't fix something that's inherently
broken when you can't get to the parts (in this, I don't mean that
the code is broken as-is in a single execution thread).
> I'd actually prefer that the interpreter dies if it is asked to load
> non-threadsafe code in a threaded context. Any threadsafe code should have
> to explicitly and programatically declare itself to be thread-safe. I'll
> take safety over speed any time.
I'll take safety over speed as well. Letting the programmer declare
that a library is thread-safe before calling it in multiple threads
is more flexible, though, than making a library declare itself
safe, in case the library is being maintained by another party.
Let the interpreter die when it finds something not specifically
declared safe in more than one thread. Let the programmer shoot
himself in the foot with a wrongful declaration, but not by default.
Also, if you let the library writer declare his library threadsafe,
what happens when that changes from platform to platform? If I
write a library that's threadsafe on Linux and shortsightedly
declare it thread-safe but the user uses it on SCO, what happens?
Sometimes the docs are a good place to make notes of this sort.
Anyway, Jarkko has asked us to stop bantering about it. Perhaps
I will throw the core on my anvil and try to beat one of these
ideas into it. I doubt I'll come up with much useful by myself,
but I'll probably come out better for the experience even if my
test copy of perl doesn't.
Chris
--
Even in the worst of times, there is always someone who's
never had it better. Even in the best of times, there is
always someone who's never had it worse.