develooper Front page | perl.perl5.porters | Postings from October 1999

Re: perlthread.pod -- First draft of thread docs

Thread Previous | Thread Next
From:
Sam Tregar
Date:
October 24, 1999 11:40
Subject:
Re: perlthread.pod -- First draft of thread docs
Message ID:
Pine.LNX.4.20.9910241435440.6598-100000@zoltar.vm.com
Some random reactions:

> When built with the appropriate options, perl provides facilities for

Which options?  Maybe it should be explicit, or at least link to where
someone could find out.

> async is not exported by default--if you want it, you need to ask for
> it when you use the Thread module. (If you don't, the code in the

Should have an example of a use statement that "asks for" async.

> Perl code must never access a variable simultaneously in two or more
> threads. The only way to safely do this is to lock the variable you're
> accessing with the lock() function. lock() is advisory, in that it
> only blocks other locks rather than actual access to a
> variable. Locks are dynamically scoped, much like the way local works,
> and stay locked until the lock goes out of scope.

Maybe I'm a dumbass, but what happens here:

use vars qw($GLOBVAR);

sub something_that_locks_globvar {
	lock($GLOBVAR);
}

lock($GLOBVAR);
something_that_locks_globvar();


Does this lock up permanently since the lock() was done already in the
main scope and then re-tried in a subroutine?  Consider that I may not be
the only fool that wonders about this...  Is it a candidate for the docs?

> The single exception is locking subroutines. If a thread locks a
> subroutine, perl will prevent any other thread from entering it until
> the lock is released.

What is the syntax for locking a subroutine?  lock(\&sub), or what?

Other than that it looks like fun stuff!  Good job.

-sam



Thread Previous | 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