
Oliver Kowalke wrote:
what about this
// use-counter in T is an atomic too array< atomic< intrusive_ptr< T > >, 100 > a;
intrusive_ptr< T > p(...); intrusive_ptr_add_ref( p.get() ); // add an intrusive_ptr to the array if ( a[index].compare_exchange_strong(null_ptr,p) ) { // successful added }
// remove an interusive_ptr from array intrusive_ptr< T > e; // points to nothing if ( ! a[index].compare_exchange_strong(e, null_ptr) ) { // successfull removed intrusive_ptr_release( e.get() ); }
For this, you don't seem to need atomic