develooper Front page | perl.perl5.porters | Postings from January 2004

Re: threads::shared::queue;

Thread Previous
Elizabeth Mattijsen
January 1, 2004 14:51
Re: threads::shared::queue;
Message ID:
At 15:21 +0100 1/1/04, Rafael Garcia-Suarez wrote:
>+=item Detached threads on Windows
>+There aren't supported yet (as of perl 5.8.3), as they may lead to
>+memory access violation problems.

I've just uploaded Thread::Detach to CPAN, which should allow you to 
use threads->detach on Windows.  From the POD:

All of this happens on Windows only and if the version of the Perl 
executor is known to have the problem.

This module replaces the standard threads->detach method with another 
subroutine that just sets an internal flag to mark the thread as 

Futhermore it uses Thread::Exit to register a subroutine that is 
executed after each thread is finished executing: this subroutine 
marks the thread as "done".

Lastly, it uses Thread::Exit to register a subroutine that is 
executed at the beginning of each thread: this subroutine reaps all 
the threads that were marked "done", hence providing the necessary 

This module should allow you to run all your threaded applications 
that used threads->detach unchanged by adding -MThread::Detach to the 
command line, or by setting the PERL5OPT environment variable.

I'm afraid I haven't been able to test this other than by faking to 
be on Windows, so if people could check whether this really fixes the 
problem, then maybe a mention of the Thread::Detach module would be 
appropriate in the perldelta.

If that is ok, then maybe the pod of threads->detach itself should 
mention the Windows problem and the temporary fix.

I wouldn't be against incorporating the functionality of 
Thread::Detach into itself, if Nick can agree to adding 
this to 5.8.3.  If that's agreeable with Nick, then I'll supply the 
necessary patches to


Thread Previous Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About