C++ 在多核MacOSX上,是以下c++;代码线程安全?
[这是侵入性refcounted指针的基础;我只想确保refcounts没有关闭]从这里看,它看起来正常。有许多公共示例可供您使用(例如来自),以进一步改进您的实现C++ 在多核MacOSX上,是以下c++;代码线程安全?,c++,multicore,thread-safety,C++,Multicore,Thread Safety,[这是侵入性refcounted指针的基础;我只想确保refcounts没有关闭]从这里看,它看起来正常。有许多公共示例可供您使用(例如来自),以进一步改进您的实现 #define atomicAdd OSAtomicAdd32Barrier class PtrInterface: public Uncopyable { private: typedef volatile int RefCount; mutable RefCount rc; public: in
#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); }
};