Re: No way to cleanup at thread exit for __thread variables?

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

 



"Kevin P. Fleming" <kpfleming@xxxxxxxxxxxxxxx> writes:

> 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.

You may be able to use pthread_cleanup_push within the thread function
itself--the function you pass to pthread_create.

> 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?

__thread variables can point to dynamically allocated storage.  But
you are correct that there is no direct analog to the cleanup function
used by pthread_key_create.

Ian

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux