views:

56

answers:

1
#define atomicAdd OSAtomicAdd32Barrier

class PtrInterface: public Uncopyable {
  private:
    typedef volatile int RefCount;
    mutable RefCount rc;
  public:
    inline void newRef() const { atomicAdd(1, &rc); }
    inline void deleteRef() const { atomicAdd(-1, &rc); }
};

[This is the basis of an invasive refcounted pointer; I just want to make sure the refcounts are not off]

+1  A: 

It looks OK from here. There are many public examples you can use (such as counter_t from the Adobe Source Libraries) to futher improve upon your implementation.

fbrereto