[fix] atomic_base
This commit is contained in:
@@ -8,11 +8,36 @@ CBase::CBase()
|
||||
|
||||
_uint CBase::AddRef()
|
||||
{
|
||||
return ++m_iRefCnt;
|
||||
return m_iRefCnt.fetch_add(1, memory_order_relaxed) + 1; // +1 한 이후의 갯수를 출력
|
||||
}
|
||||
|
||||
_uint CBase::Release()
|
||||
{
|
||||
for (;;)
|
||||
{
|
||||
_uint iOldRefCount = m_iRefCnt.load(memory_order_acquire);
|
||||
|
||||
if (iOldRefCount == 0u) // -1 할 때 갯수가 0이면 소멸
|
||||
{
|
||||
Free();
|
||||
|
||||
delete this;
|
||||
|
||||
return 0u;
|
||||
}
|
||||
|
||||
_uint iNewRefCount = iOldRefCount - 1u;
|
||||
|
||||
if (m_iRefCnt.compare_exchange_weak(
|
||||
iOldRefCount,
|
||||
iNewRefCount,
|
||||
memory_order_acq_rel,
|
||||
memory_order_acquire))
|
||||
{
|
||||
return iNewRefCount; // -1 한 이후의 갯수를 출력함을 보장
|
||||
}
|
||||
}
|
||||
|
||||
if (0 == m_iRefCnt)
|
||||
{
|
||||
Free();
|
||||
|
||||
@@ -5,6 +5,15 @@ CBone::CBone()
|
||||
{
|
||||
}
|
||||
|
||||
CBone::CBone(const CBone& other)
|
||||
{
|
||||
memcpy_s(m_szName, sizeof(_char) * MAX_PATH, other.m_szName, sizeof(_char) * MAX_PATH);
|
||||
m_TransformationMatrix = other.m_TransformationMatrix;
|
||||
m_CombinedTransformationMatrix = other.m_CombinedTransformationMatrix;
|
||||
m_iParentBoneIndex = other.m_iParentBoneIndex;
|
||||
m_matInitial = other.m_matInitial;
|
||||
}
|
||||
|
||||
void CBone::Get_KeyFrame(KEYFRAME& kf, _bool bIsCurrentFrame)
|
||||
{
|
||||
_vector vScale = {};
|
||||
|
||||
@@ -306,7 +306,7 @@ void CGameInstance::Present_TimeCost() const
|
||||
GUI::SameLine(0.f, GUI::GetStyle().ItemInnerSpacing.x);
|
||||
GUI::Text("Timer_Occupancy %d", int(m_fTimer_Present / fTotal * 100.f));
|
||||
}
|
||||
GUI::Text("GameInstance RefCNT : %d", m_iRefCnt);
|
||||
GUI::Text("GameInstance RefCNT : %d", m_iRefCnt.load());
|
||||
static float values[60] = {};
|
||||
static int values_offset = 0;
|
||||
static double refresh_time = 0.0;
|
||||
|
||||
@@ -16,10 +16,10 @@ class ENGINE_DLL CBase abstract
|
||||
_uint Release();
|
||||
|
||||
protected:
|
||||
_uint m_iRefCnt = {};
|
||||
atomic<_uint> m_iRefCnt = { 0 };
|
||||
|
||||
public:
|
||||
virtual void Free();
|
||||
};
|
||||
|
||||
NS_END
|
||||
NS_END
|
||||
|
||||
@@ -8,6 +8,7 @@ class ENGINE_DLL CBone final : public CBase
|
||||
{
|
||||
private:
|
||||
CBone();
|
||||
CBone(const CBone& other);
|
||||
virtual ~CBone() = default;
|
||||
public:
|
||||
_matrix Get_CombinedTransformationMatrix() const {
|
||||
@@ -59,4 +60,4 @@ class ENGINE_DLL CBone final : public CBase
|
||||
|
||||
};
|
||||
|
||||
NS_END
|
||||
NS_END
|
||||
|
||||
Reference in New Issue
Block a user