At 10:23 AM 6/25/2001 -0500, David M. Lloyd wrote:
>Is it safe to have an XS module that uses threads with a non-threaded
>Perl, as long as the threads do not call the Perl API? Is there anything
>I should look out for?
That depends. Generally I'd say no, it isn't.
The problem that generally arises is that there sometimes (depending on
your platform, I'd expect) needs to be some magic done at program startup
time to support threads. This setup normally can *not* be done once the
program's started--its at the beginning or never. Unfortunately, when you
dynamically activate a library that needs pthreads, it'll assume that this
initialization has already been done and fail because it hasn't, or try to
set things up and fail because it's too late. Either way, you're kinda hosed.
What I've found I need to do to support this (Yes, I have been bitten...)
is to build perl and force it to use the thread libraries. It doesn't
actually need to be built with perl threads, just with the threading
libraries linked in. I had to force this with a call to decc$setreentrancy
on VMS, but this is pretty platform dependent. (Any call to a pthread
routine is likely enough, and adding -pthread to your compile and link
steps might be enough as well)
Dan
--------------------------------------"it's like this"-------------------
Dan Sugalski even samurai
[EMAIL PROTECTED] have teddy bears and even
teddy bears get drunk