[fitz-dev] On the fitz global context
Dan Maas
dmaas at maasdigital.com
Tue Dec 23 07:42:44 PST 2003
> However, I don't like it much, and move to eliminate the global
> context as passed around everywhere and make it global (or thread
> local storage) with functions like OpenGL to change the current
> context.
I am a big fan of this pattern. OpenGL got it right... You have a
"global" context (where "global" means really global in a
single-threaded program, or "thread-local" in a multi-threaded
program).
Although you'll have to be careful how to implement TLS, since that
can harm binary compatibility (native compiler support for TLS is
"evolving," and I don't like programs that link to libpthread.so
unless they really use multiple threads...)
It's probably a good idea to have a push/pop stack of contexts, if
there is any chance users would need more than one at a time.
Regards,
Dan
More information about the fitz-dev
mailing list