develooper Front page | perl.perl5.porters | Postings from November 2003

creating threads in BEGIN

Thread Next
From:
Nicholas Clark
Date:
November 12, 2003 14:22
Subject:
creating threads in BEGIN
Message ID:
20031112222134.GL6287@plum.flirble.org
Foolish me. I'm about to try to start a more heat than light thread.

It has been suggested to me that perl doesn't support creating ithreads
at BEGIN time.

I'm not convinced that this constraint is tenable or desirable.

If it is true that one mustn't spawn a new thread inside a BEGIN block,
then it means that all code executing as a result of use mustn't spawn
threads. 

This would mean that any subroutine or method that causes a thread to
be spawned must document this explicitly. (or mark itself non-BEGIN safe)

Otherwise, how is module A's startup code to know that it should not
call a method in module B, where B happens to use threads in its
implementation? Particularly if B wants to keep its implementation private,
so that it can change it in future if needs be.

Nicholas Clark

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About