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

creating threads in BEGIN

Thread Next
Nicholas Clark
November 12, 2003 14:22
creating threads in BEGIN
Message ID:
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

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 Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About