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

Re: [PATCH] cond_wait() and arbitrary lock variables

Thread Previous | Thread Next
Elizabeth Mattijsen
November 24, 2003 06:15
Re: [PATCH] cond_wait() and arbitrary lock variables
Message ID:
At 07:52 -0600 11/24/03, Mike Pomraning wrote:
>The following patch against 5.8.2 allows a shared variable to be cond_wait()d
>with a distinct, shared lock variable:
>    use threads::shared;
>    cond_wait($v);           # $v is both condition and mutex
>    cond_wait($v, $v);       # same as above, but explicit
>    cond_wait($v, $lockvar); # $v's predicate is protected by $lockvar, which
>                             # presumably protects other predicates as well
>This is useful for, e.g., a Queue object which has client threads waiting on
>one of two interesting predicates:  "items ready" ($q->dequeue) or "queue
>empty" ($q->await_empty).

I'm probably dense, but I don't see the application of this (yet). 
Could you elaborate?  How would this be different from using nested 
locks?  Or is this a quicker way to do that?

Questions, questions, questions...  ;-)   Just wondering if and when 
I would need to add similar functionality to   ;-)


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