[vlc-devel] [vlc-commits] addons: fix threading and cancelable sections
Steinar H. Gunderson
sgunderson at bigfoot.com
Thu Feb 20 19:49:02 CET 2014
On Thu, Feb 20, 2014 at 08:30:04PM +0200, Rémi Denis-Courmont wrote:
> I seem to see the predicate-less condition variable antipattern yet again :-(
>From experience, the simplest way to avoid this antipattern is to simply
encapsulate the correct one in a function call. It becomes a bit verbose
when you don't have std::function and the likes, though.
E.g.,
bool MyLittlePredicate( void* arg ) {
// mutex is locked in this function
return (some_global == 3);
}
WaitFor( &mutex, &condvar, MyLittlePredicate, NULL );
Much harder to get wrong for the user.
/* Steinar */
--
Homepage: http://www.sesse.net/
More information about the vlc-devel
mailing list