This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
No way to cleanup at thread exit for __thread variables?
- From: "Kevin P. Fleming" <kpfleming at starnetworks dot us>
- To: gcc-help at gcc dot gnu dot org
- Date: Thu, 23 Aug 2007 12:20:38 -0500
- Subject: No way to cleanup at thread exit for __thread variables?
I'm considering converting an application that uses pthread_key_XXX
methods for thread local storage over to using GCC's native support (the
__thread attribute), since it should be significantly more efficient.
However, I find myself at a loss to figure how this is intended to be
used for dynamically sized variables... for example, what if I wanted to
have each thread have a separate linked list of items it was supposed to
process? There does not appear to be any way to clean these entries up
at thread exit time, whereas pthread_key_create gives me the option of
providing a cleanup function.
pthread_cleanup_push() and _pop() are really not appropriate for this,
as they are designed to be used within a single function's scope of
execution.
Am I missing something here? Is gcc's __thread support really only
usable for variables that are not (or don't contain) pointers to
dynamically allocated storage?