[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [ft] Clarification about FT_Init_FreeType in a multithreaded environ
From: |
Ulrich Eckhardt |
Subject: |
Re: [ft] Clarification about FT_Init_FreeType in a multithreaded environment |
Date: |
Thu, 13 Jun 2013 10:16:39 +0200 |
User-agent: |
Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/20130509 Thunderbird/17.0.6 |
Am 12.06.2013 19:02, schrieb Werner LEMBERG:
If you can guarantee that you don't render multiple glyphs at the same
time in parallel, one FT_Library object for all threads certainly
works. But this is something which I won't call thread-safe (please
correct me if I'm mixing up definitions).
I would call that "thread-safe when used correctly". ;) Since rendering
changes internal state of the library object (raster pool), it must not
be done concurrently.
So a program with multiple threads should use `FT_New_Library' and
`FT_Done_Library' (instead of `FT_Init_FreeType' and
`FT_Done_FreeType'), providing its own FT_Memory object.
Okay...? I must admit that I don't fully understand this part of
your answer yet, probably because I don't understand FreeType's
structure enough. It seems that this also influences my other
approaches above, I'll have to verify that.
`With multiple threads' implies parallel access of FreeType. I would
be glad if you could formulate this better!
Maybe I can help out here. The sentence that confused me was:
For multi-threading applications each thread should have
its own FT_Library object.
which I would replace with:
In multi-threaded applications, you must make sure that
you don't access the same FT_Library object or any of
its children in parallel.
Actually, this paragraph in CHANGES sums it up, too:
- thread synchronisation has been dropped, for the simple reason
that the library is already re-entrant, and that if you really
need two threads accessing the same FT_Library, you should
really synchronize access to it yourself with a simple mutex.
I added the reference to the children because the FT_Library object is
only one handle into a whole tree of objects (see diagram at the end of
http://www.freetype.org/freetype2/docs/design/design-4.html), but other
objects (faces, glyphs) are also part of the library and must not be
used in parallel either (right?).
Thank you for your help!
Uli
**************************************************************************************
Domino Laser GmbH, Fangdieckstra�e 75a, 22547 Hamburg, Deutschland
Gesch�ftsf�hrer: Hans Robert Dapprich, Amtsgericht Hamburg HR B62 932
**************************************************************************************
Visit our website at http://www.dominolaser.com
**************************************************************************************
Diese E-Mail einschlie�lich s�mtlicher Anh�nge ist nur f�r den
Adressaten bestimmt und kann vertrauliche Informationen enthalten. Bitte
benachrichtigen Sie den Absender umgehend, falls Sie nicht der beabsichtigte
Empf�nger sein sollten. Die E-Mail ist in diesem Fall zu l�schen und darf
weder gelesen, weitergeleitet, ver�ffentlicht oder anderweitig benutzt werden.
E-Mails k�nnen durch Dritte gelesen werden und Viren sowie nichtautorisierte
�nderungen enthalten. Domino Laser GmbH ist f�r diese Folgen nicht
verantwortlich.
**************************************************************************************