[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Devel] FreeType Cache in multithread program

From: Vincent Caron
Subject: Re: [Devel] FreeType Cache in multithread program
Date: Thu, 13 Feb 2003 12:19:55 +0100
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.2a) Gecko/20020910

Jan Slupski wrote:

How FreeType Cache (and FreeType itself) works in multithread environment?

FreeType does not have any provision for multithread safety, it's up to the user to manage ressource access contention. FreeType does not use any global at all, so it's actually easy to manage contention :)

Is it all right to have only one Cache structure created for use by
multiple threads, or it's necessary to have one cache per thread?

If you access this single cache instance from different threads without a mutex, that could lead to strange things indeed. For instance, if you happen to fetch a glyph from the cache while a new one is being inserted in another thread, I guess you'll end up reading from an inconsistent hashtable and get a bad glyph (TM), potentially from any face that happened to cross that cache. Fetching a glyph from the cache is not a read-only operation since it can trigger a rendering (when the glyph's not there).

I don't recommend having multiple cache instances until having a very good reason, since it's easier to manage memory usage limits from a single cache.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]