2025-04-27 07:49:33 -04:00

26 lines
459 B
C++

#ifndef _REFCNT_H_
#define _REFCNT_H_
class CRefCount
{
public:
CRefCount() : _cRCRef(1) {}
ULONG AddRef() { return ::InterlockedIncrement((LONG*)&_cRCRef); }
ULONG Release()
{
ULONG cRef = ::InterlockedDecrement((LONG*)&_cRCRef);
if (!cRef)
{
delete this;
}
return cRef;
}
private:
ULONG _cRCRef; // RC: to avoid name colision
};
#endif // _REFCNT_H_