[Xr] Can the xrs argument be removed?
cworth at east.isi.edu
Thu May 22 12:58:20 PDT 2003
On May 21, Bill Spitzak wrote:
> I would like to recommend that you remove the "XrState*" argument from Xr,
> and make it work much more like OpenGL where there is an implied static
> context variable.
Thanks for the suggestion. This would be quite convenient.
I'll confess that I don't have much experience with TLS, so I have
some questions on the implementation. For example, what is the
best/most portable approach?
I see there's the pthread_key_create/pthread_setspecific stuff.
There's also the gcc __thread extension which is documented to support
IA-32, IA-64, SPARC (32-bit and 64-bit), SuperHitachi (SH), Alpha,
x86-64, and S390 (31-bit and 64-bit).
One thing that seems problematic to me is the semantics of at least
the gcc implementation:
When a thread terminates, any pointers to thread-local
variables in that thread become invalid. 
What could we do to either avoid or detect the problem if one thread
tries to call XrSetState with a TLS pointer from another thread that
has already terminated?
> Because the method used to make thread-local static variables is hidden this
> is also much more portable than any solution a user of Xr can do.
Well, because it's hidden it's different than what the user might
do. It's not necessarily more portable, and I'd definitely want to
avoid making it any worse.
Further recommendations are definitely welcome,
USC Information Sciences Institute cworth at isi.edu
More information about the cairo