Boost logo

Boost :

From: Alexander Terekhov (terekhov_at_[hidden])
Date: 2004-06-08 09:58:31


Johan Nilsson wrote:
[...]
> Do you mean that the "destructors" can allocate/use tss under execution, or?

<quote>

After all cancellation cleanup handlers have been executed, if
the thread has any thread-specific data, appropriate destructor
functions shall be called in an unspecified order. [...] Both
pthread_getspecific() and pthread_setspecific() may be called
from a thread-specific data destructor function. A call to
pthread_getspecific() for the thread-specific data key being
destroyed shall return the value NULL, unless the value is
changed (after the destructor starts) by a call to
pthread_setspecific(). Calling pthread_setspecific() from a
thread-specific data destructor routine may result either in
lost storage (after at least PTHREAD_DESTRUCTOR_ITERATIONS
attempts at destruction) or in an infinite loop.

</quote>

> What is the definition of "destructors" under pthreads, anyway (I assume
> it's not the same as a C++ destructor)?

It's extern "C" void (*destructor)(void*));

<quote>

An optional destructor function may be associated with each
key value. At thread exit, if a key value has a non-NULL
destructor pointer, and the thread has a non-NULL value
associated with that key, the value of the key is set to
NULL, and then the function pointed to is called with the
previously associated value as its sole argument. The order
of destructor calls is unspecified if more than one
destructor exists for a thread when it exits. If, after all
the destructors have been called for all non-NULL values
with associated destructors, there are still some non-NULL
values with associated destructors, then the process is
repeated. If, after at least {PTHREAD_DESTRUCTOR_ITERATIONS}
iterations of destructor calls for outstanding non-NULL
values, there are still some non-NULL values with associated
destructors, implementations may stop calling destructors,
or they may continue calling destructors until no non-NULL
values with associated destructors exist, even though this
might result in an infinite loop.

</quote>

regards,
alexander.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk