[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [ft-devel] thread and non-thread safe issues
From: |
Werner LEMBERG |
Subject: |
Re: [ft-devel] thread and non-thread safe issues |
Date: |
Fri, 21 Aug 2015 22:40:05 +0200 (CEST) |
> I'm currently using freetype to create a simple demo of my further
> project, and I've noticed that I cannot use FTC_ImageCache_Lookup
> and FTC_Manager related functions at same time in different threads.
> It is documented that we can't operate ft_library or some other
> struct simultaneously, but I didn't find a conclusion or some kind
> of multithread programming guideline document that figures out all
> thread safety issues. Can you please give a note on that?
We have the following in the CHANGES file for version 2.6.
- Behdad Esfahbod contributed code for improved thread-safety,
which results in the following model.
* An `FT_Face' object can only be safely used from one thread at
a time.
* An `FT_Library' object can now be used without modification
from multiple threads at the same time.
* `FT_Face' creation and destruction with the same `FT_Library'
object can only be done from one thread at a time.
One can use a single `FT_Library' object across threads as long
as a mutex lock is used around `FT_New_Face' and `FT_Done_Face'.
Any calls to `FT_Load_Glyph' and similar API are safe and do not
need the lock to be held as long as the same `FT_Face' is not
used from multiple threads at the same time.
Note that I have no experience in thread safety code. However, since
the cache code is essentially based on FT_Face objects, I believe that
you have to use separate caches for different threads. Maybe this can
be improved, but unfortunately I'm the wrong guy to do this.
Werner