[cairo] Re: Atomic reference counting

Ross Burton ross at burtonini.com
Mon Apr 2 08:30:36 PDT 2007


On Mon, 2007-04-02 at 10:58 -0400, Kristian Høgsberg wrote:
> 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.

Agreed.  I find it a bit irritating that GLib's atomic ints are plain
"volatile int" because its easy to forget and use the normal operators.

Ross
-- 
Ross Burton                                 mail: ross at burtonini.com
                                          jabber: ross at burtonini.com
                                     www: http://www.burtonini.com./
 PGP Fingerprint: 1A21 F5B0 D8D0 CFE3 81D4 E25A 2D09 E447 D0B4 33DF





More information about the cairo mailing list