Question

#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]

No correct solution

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top