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

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

Thread Previous | Thread Next
From:
Tuomas J. Lukka
Date:
October 26, 1999 01:41
Subject:
Re: perlthread.pod -- First draft of thread docs
Message ID:
Pine.LNX.3.96.991026113911.9533T-100000@fuga.mit.jyu.fi
On Sun, 24 Oct 1999, Dan Sugalski wrote:
> Just out of curiosity, why? I presume it's unlock in addition to locks
> getting released when they fall out of scope. I can see the occasional
> need, but I don't know that it'd be used enough to justify the extra
> hassles involved.

Yes, exactly: the occasional need. When you need to acquire two locks
in a different order than you want to release them. For instance, if you
want to walk along a tree structure, first locking the root to get
the next branch, then unlocking the root so that others can walk as
well.

Simple things simple (lock with autounlock at end of block), complicated
things possible (lock with unlock).

Actually, I think that maybe

	$lock = lock $obj;

	undef $lock;

would make a nice interface: then

	{
		my $lock = lock $obj
	}

would do the same as C<lock> does by default but if you want, you can
save the $lock variable somewhere.

And no, I'm not advocating removing the current functionality. Only adding
the ability to somehow get rid of locks earlier.

	Tuomas


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