[cairo] Atomic reference counting

Kristian Høgsberg krh at bitplanet.net
Mon Apr 2 07:58:25 PDT 2007


On 4/2/07, Chris Wilson <chris at chris-wilson.co.uk> wrote:
> As has been discussed numerous times on this list (ok, at least twice ;-)
> Cairo is suitable to races in it reference counting. This was most
> recently exposed by the flawed solid pattern cache since the shared
> colours are destroyed and reference with a high frequency.
>
> The solution as proposed on this list, and used elsewhere, is to implement
> atomic reference counting along with a strict policy on when references
> must be taken.

What about introducing

  typedef struct {
      unsigned int value;
  } cairo_atomic_t;

and use that for ref counts to let the type checker make sure we only
ever manipulate the ref counts using the atomic operations.  The
atomic integer operations have to be changed to take a pointer to this
struct and we need a getter and a setter, of course.

cheers,
Kristian


More information about the cairo mailing list