On Fri, 2002-09-20 at 23:06, Thomas Pfaff wrote:

> If you want to work around this you must use a mutex to protect the entire
> list.

Or: don't delete foo; the keys, instead foo->deleteme();

pthread_key::pthread_key(){
  inuse_count = 1;
}

pthread_key::deleteme() {
  interlockedincrement(inuse_count)
  if interlockeddecrement (inuse_count) == 0
    delete this;
}


pthread_key::rundestructor() {
if (interlockeddecrement(inuse_count) == 0)
  delete this
}

This prevents the race you describe with no locks.

Still, this race is actually one ieee says we don't care about IIRC,
it's up to the user to synchronise calls like this.
Rob

Attachment: signature.asc
Description: This is a digitally signed message part

Reply via email to