?? kinterlockedcounter.cpp
字號(hào):
#include "KInterlockedCounter.h"
KInterlockedCounter::KInterlockedCounter(LONG nStartValue)
{
InterlockedExchange(&m_nValue, nStartValue);
}
KInterlockedCounter::KInterlockedCounter(const KInterlockedCounter& right)
{
new (this) KInterlockedCounter(right.m_nValue);
}
KInterlockedCounter::~KInterlockedCounter()
{
}
KInterlockedCounter& KInterlockedCounter::operator=(const KInterlockedCounter& right)
{
new (this) KInterlockedCounter(right.m_nValue);
return *this;
}
KInterlockedCounter& KInterlockedCounter::operator=(const LONG nValue)
{
new (this) KInterlockedCounter(nValue);
return *this;
}
KInterlockedCounter& KInterlockedCounter::operator++()
{
InterlockedIncrement(&m_nValue);
return *this;
}
KInterlockedCounter& KInterlockedCounter::operator--()
{
InterlockedDecrement(&m_nValue);
return *this;
}
const KInterlockedCounter KInterlockedCounter::operator++(int)
{
KInterlockedCounter Old = *this;
++(*this);
return Old;
}
const KInterlockedCounter KInterlockedCounter::operator--(int)
{
KInterlockedCounter Old = *this;
--(*this);
return Old;
}
BOOLEAN KInterlockedCounter::CompareExchange(const LONG nValueComperand, const LONG nValueExchange)
{
#ifndef __WIN2K
if (InterlockedCompareExchange((PVOID*)&m_nValue, (PVOID)nValueExchange, (PVOID)nValueComperand) == (PVOID)nValueComperand)
return TRUE;
#else
if (InterlockedCompareExchange(&m_nValue, nValueExchange, nValueComperand) == nValueComperand)
return TRUE;
#endif //__WIN2K
return FALSE;
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -