summaryrefslogtreecommitdiff
path: root/src/cairo-xlib-screen.c
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2007-09-23 21:08:09 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2007-09-25 16:29:54 +0100
commit03be41151d06d48d55bc1e172535829ec45a10cf (patch)
tree4dc280d45c96a39b681065386ab817099cfb65bd /src/cairo-xlib-screen.c
parent8b6c871c9084739460f1320cd36560a09477a83e (diff)
downloadcairo-03be41151d06d48d55bc1e172535829ec45a10cf.tar.gz
[cairo-atomic] Rewrite reference counting using atomic ops.
Introduce an opaque cairo_reference_count_t and define operations on it in terms of atomic ops. Update all users of reference counters to use the new opaque type.
Diffstat (limited to 'src/cairo-xlib-screen.c')
-rw-r--r--src/cairo-xlib-screen.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/cairo-xlib-screen.c b/src/cairo-xlib-screen.c
index 88f089993..578a33a69 100644
--- a/src/cairo-xlib-screen.c
+++ b/src/cairo-xlib-screen.c
@@ -246,8 +246,9 @@ _cairo_xlib_screen_info_reference (cairo_xlib_screen_info_t *info)
if (info == NULL)
return NULL;
- assert (info->ref_count > 0);
- info->ref_count++;
+ assert (CAIRO_REFERENCE_COUNT_HAS_REFERENCE (&info->ref_count));
+
+ _cairo_reference_count_inc (&info->ref_count);
return info;
}
@@ -274,8 +275,9 @@ _cairo_xlib_screen_info_destroy (cairo_xlib_screen_info_t *info)
if (info == NULL)
return;
- assert (info->ref_count > 0);
- if (--info->ref_count)
+ assert (CAIRO_REFERENCE_COUNT_HAS_REFERENCE (&info->ref_count));
+
+ if (! _cairo_reference_count_dec_and_test (&info->ref_count))
return;
CAIRO_MUTEX_LOCK (info->display->mutex);
@@ -330,7 +332,7 @@ _cairo_xlib_screen_info_get (Display *dpy, Screen *screen)
} else {
info = malloc (sizeof (cairo_xlib_screen_info_t));
if (info != NULL) {
- info->ref_count = 2; /* Add one for display cache */
+ CAIRO_REFERENCE_COUNT_INIT (&info->ref_count, 2); /* Add one for display cache */
info->display = _cairo_xlib_display_reference (display);
info->screen = screen;
info->has_render = FALSE;