[cairo] Re: Sorry I broke the text tests! (and status update)

Behdad Esfahbod behdad at behdad.org
Thu Feb 15 10:10:55 PST 2007


On Thu, 2007-02-15 at 17:28 +0800, Jinghua Luo wrote:
> 
> > Thanks Koen.  That gave me the confidence to push it.  It's in
> master
> > now: commit 2715f2098127d04d2f9e304580a26cd0842c0e64
> >   
> This patch is likely to break win32 and os2 backend which has to 
> explicitly create a mutex.

Good point.  I'm trying to clean this up, but someone with some win32
knowledge and access can do a far better job.

While at it, I think we should fix this correctly this time.  The list
of mutexes initialized in _cairo_win32_initialize() was already out of
synch.  The &cairo_toy_font_face_hash_table_mutex is not used anymore,
and there are new ones that are not initialized.

So I suggest we:

  - Move all mutex macros from cairoint.h into cairo-mutex-private.h.
We should really move stuff out of cairoint.h.  Currently editing that
file causes a full rebuild and that's not quite productive.

  - Move all mutex declarations into a header cairo-mutex-list-private.h
This will include cairo-features.h and use the CAIRO_HAS_* and
CAIRO_MUTEX_DECLARE macros to define exactly those mutexes needed.

  - In cairo-mutex-private.h, after all macro definitions based on the
available system, we include cairo-mutex-list-private.h to declare all
mutexes and then undefine CAIRO_MUTEX_DECLARE.  This makes sure static
mutexes are not defined anywhere else in the code.

  - In cairo-mutex.c, we redefine CAIRO_MUTEX_DECLARE and include
mutex-list again to actually define the mutexes, and implement a
function _cairo_mutex_init() that redefines CAIRO_MUTEX_DECLARE and
include mutex-list again, to initialize them.

  - Have a public _cairo_mutex_initialized boolean.  Define a macro
CAIRO_MUTEX_INITALIZE() that is a no-op on pthread systems, and expands
to "do { if (!_cairo_mutex_initialized) _cairo_mutex_initialize() }
while(0)".

  - Call CAIRO_MUTEX_INITIALIZE() in all entry points to cairo.  That is
I guess:

    - All surface_create() functions.
    - All font_face_create() functions.
    - All pattern_create() functions.

Alternatively, it may be enough if we do it only in:

    - cairo_create()
    - cairo_scaled_font_create()

But that way we have to remember where we can use a mutex and where we
can't.  To fix that of course we can warn if a mutex is used
uninitialized in debugging builds.  Though we don't have that concept
(debugging build) yet.

Duh.  This is the nearest you can get to writing code in email.  Anyway,
lets comment soon and get this implemented (hint, hint).


-- 
behdad
http://behdad.org/

"Those who would give up Essential Liberty to purchase a little
 Temporary Safety, deserve neither Liberty nor Safety."
        -- Benjamin Franklin, 1759





More information about the cairo mailing list