[vlc-devel] [PATCH v2 01/10] core: add atomic refcounter helper

Romain Vimont rom1v at videolabs.io
Mon Jul 2 20:09:03 CEST 2018

On Mon, Jul 02, 2018 at 08:19:01PM +0300, Rémi Denis-Courmont wrote:
> Le maanantaina 2. heinäkuuta 2018, 19.55.12 EEST Romain Vimont a écrit :
> > On Mon, Jul 02, 2018 at 06:56:57PM +0300, Rémi Denis-Courmont wrote:
> > > I prefer thread fence over release order but I still don't know any way to
> > > make a helper without removing asserts, and I don't want to remove
> > > asserts.
> > Either:
> >  0. we remove these refcount asserts (you don't want that);
> *Nobody* wants to remove asserts, AFAIK.

TBH, I would not be against removing these specific asserts, since I
think they have low value (but maybe I am missing something).

Concretely, they test whether the refcount was positive before inc() or

But if it was 0, a dec() to 0 already occurred, so the object embedding
the refcount has typically been freed. If instead, the error was that
the user forgot to destroy on last-dec(), then the assert() does not
capture it anyway.

Since we talked about the linux implementation earlier (e.g.
atomic_dec_and_test()), they don't assert here.

More information about the vlc-devel mailing list