|
Boost : |
From: alnsn_at_[hidden]
Date: 2004-07-09 13:43:38
Eric Niebler wrote:
> alnsn_at_[hidden] wrote:
> >
> >This is a degenerate case of more general idea of passing lock reference
> >to functions inside condition:
> >
> >if(lock_ref l = scoped_lock(m))
> >{
> > // do something with l:
> > action1(l);
> > action2(l);
> >}
> >
> >Apparently, action1 and action2 can't be called without prior obtaining
> >of a lock.
> >Plus, you get some sort of polymorphism because the functions can accept
> >other locks as well:
> >
> >action1(scoped_try_lock(m1)); // lock_ref is const reference
> >action2(scoped_timed_lock(m2));
> >
>
>
> Oh yeah, I heard a talk by Andrei Alexandrescu in which he endorsed that
> idiom. (Google for "Honey I shrunk the threads".) I like it, but I've
> never used it. :-P
I know he gave a talk at ACCU this year but I missed the event.
And there is nothing on his site yet. Not a problem anymore ;-)
Though, I was able to download Kevlin's presentation.
-- Alexander Nasonov
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk