
Vicente Botet Escriba wrote:
More, any non-constant time operator* don't satisfy my requirements for some specific contexts.
I don't think that any implementation gives you this constant time guarantee if you continually create thread-specific variables.
When you say "continually create thread-specific variables" do you mean without removing them.
Stefan's idea was to reuse slots in the vector. This would avoid reallocation when keys are created and destroyed at the same rate. Unfortunately, on second thought, this isn't as straightforward as it seemed; threads could still hold non-NULL pointers when the key is destroyed. pthread_key_delete simply discards these non-NULL pointers without cleaning them up; the current implementation performs proper cleanup when the threads end.