[HarfBuzz] [PATCH] Implement threading primitives on Windows; fix compile error and leak
Behdad Esfahbod
behdad at behdad.org
Tue May 3 13:09:18 PDT 2011
On 05/03/11 15:56, Bradley Grainger wrote:
> The current code is incorrect because InitializeCriticalSection must be called on a CRITICAL_SECTION for Windows to consider it valid; it's not sufficient to just zero out the fields of the structure.
>
> There's no built-in analogue to G_STATIC_MUTEX_INIT on Windows, but now that I've looked through the glib code a little, I see that it could be written in the same way glib does it (i.e., initialise static mutexes on demand the first time they're used by taking a different global mutex that protects static mutex initialisation).
>
> If static mutexes could be avoided, it could make cross-platform portability easier. (And there might be a minor performance gain from not having to enter a global mutex in order to initialise static mutexes.)
Ah, you're right. I was copying from cairo and forgot that we initialize
static mutexes there.
Now, you may notice that as it stands, right now we don't use any static
mutex. So, I can just go ahead an initialize them all. But I was planning on
using static mutexes to make static data initialization (like hb_language
stuff) threadsafe.
I think I need to study the glib code. It's not clear to me how to initialize
the global mutex initialization mutex safely :).
I'll get back to you.
behdad
More information about the HarfBuzz
mailing list