[stuff cutted]
>
> It looks like we have the following choices:
>
> 1.  Not support read-only thread safety.
> 2.  Support read-only thread safety at the sacrifice of leaking memory and
> limiting implementation memory models (current IDOM).
> 3.  Support read-only thread safety as you suggest by performing thread
safe
> increments and decrements with the possibility that some performance is
> lost.
>
> If #3 does affect performance, then perhaps read-only thread safety can be
> made an option so that those that don't need it don't pay for it.

The #3 probably has negligable affect on performance as long as there are
support in the platform hardware for atomic operations like test and set.
Most processors do have this support and it is also often directly supported
by the operating system. But making it optional with a compiler flag is not
that hard either.

void Node::IncRef()
{
#ifdef THREADSAFETY
  enter critical section (implemented with a semaphore, mutex, lock or
whatever)
#endif

  nRefs++;

#ifdef THREADSAFETY
  leave critical section
#endif
}

Regards

Erik Rydgren
Mandarinen systems AB
Sweden


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to