[cairo] Static caches and thread-safety
Carl Worth
cworth at cworth.org
Thu Nov 11 19:09:20 PST 2004
On Thu, 11 Nov 2004 13:10:15 -0800, Bill Spitzak wrote:
> Sorry, attached the wrong version. This one uses the recursive lock on Linux
> if it can:
I think in this case we don't even need a recursive lock. But I had
already found the _GNU_SOURCE thing in order to get an error-checking
mutex for when compiling with assertions enabled. That seems useful.
> /* STOOPID WINDOWS! This next line is not thread-safe. It would help
> if there were a compile-time initializer for the semaphore. Otherwise
> the only thread-safe solution is to initialize this code on startup
> when you know there are no other threads... */
> if (!initialized) {initialized=true; InitializeCriticalSection(&cs);}
Ugh. Is that really the best one can do there?
On second thought, don't tell me. I really don't want to know.
I'm half tempted to move the caches down into cairo_t and encourage
users to clone from a single call to cairo_create if they want to get
all the sharing benefits...
Keeping locking out of cairo definitely seems appealing. And I wouldn't
guess that it would be common for less-informed users to want to make
lots of simultaneous cairo_t objects. Stupid?
Thread-local storage?
Nothing seems perfectly clean here. Dirty, dirty...
-Carl
More information about the cairo
mailing list