1
0
mirror of https://foundry.openuru.org/gitblit/r/CWE-ou-minkata.git synced 2025-07-17 10:52:46 +00:00

More std::atomic and friends

This commit is contained in:
2014-04-08 21:38:46 -07:00
parent 23a071860e
commit 34b2eb1836
15 changed files with 61 additions and 94 deletions

View File

@ -1208,7 +1208,7 @@ static ShaDigest s_accountNamePassHash;
static wchar_t s_authToken[kMaxPublisherAuthKeyLength];
static wchar_t s_os[kMaxGTOSIdLength];
static long s_perf[kNumPerf];
static std::atomic<long> s_perf[kNumPerf];
static uint32_t s_encryptionKey[4];
@ -1596,14 +1596,14 @@ CliAuConn::CliAuConn ()
{
memset(name, 0, sizeof(name));
AtomicAdd(&s_perf[kPerfConnCount], 1);
++s_perf[kPerfConnCount];
}
//============================================================================
CliAuConn::~CliAuConn () {
if (cli)
NetCliDelete(cli, true);
AtomicAdd(&s_perf[kPerfConnCount], -1);
--s_perf[kPerfConnCount];
}
//===========================================================================

View File

@ -77,7 +77,7 @@ struct ReportNetErrorTrans : NetNotifyTrans {
***/
static FNetClientErrorProc s_errorProc;
static long s_initCount;
static std::atomic<long> s_initCount;
/*****************************************************************************
@ -143,7 +143,7 @@ void ReportNetError (ENetProtocol protocol, ENetError error) {
//============================================================================
void NetClientInitialize () {
if (0 == AtomicAdd(&s_initCount, 1)) {
if (0 == s_initCount.fetch_add(1)) {
NetTransInitialize();
AuthInitialize();
GameInitialize();
@ -160,7 +160,7 @@ void NetClientCancelAllTrans () {
//============================================================================
void NetClientDestroy (bool wait) {
if (1 == AtomicAdd(&s_initCount, -1)) {
if (1 == s_initCount.fetch_sub(1)) {
s_errorProc = nil;
GateKeeperDestroy(false);

View File

@ -225,7 +225,7 @@ static bool s_running;
static CCritSect s_critsect;
static LISTDECL(CliFileConn, link) s_conns;
static CliFileConn * s_active;
static long s_perf[kNumPerf];
static std::atomic<long> s_perf[kNumPerf];
static unsigned s_connectBuildId;
static unsigned s_serverType;
@ -588,7 +588,7 @@ CliFileConn::CliFileConn ()
, pingTimer(nil), pingSendTimeMs(0), lastHeardTimeMs(0)
{
memset(name, 0, sizeof(name));
AtomicAdd(&s_perf[kPerfConnCount], 1);
++s_perf[kPerfConnCount];
}
//============================================================================
@ -596,7 +596,7 @@ CliFileConn::~CliFileConn () {
ASSERT(!cancelId);
ASSERT(!reconnectTimer);
Destroy();
AtomicAdd(&s_perf[kPerfConnCount], -1);
--s_perf[kPerfConnCount];
}
//===========================================================================

View File

@ -156,7 +156,7 @@ static LISTDECL(CliGmConn, link) s_conns;
static CliGmConn * s_active;
static FNetCliGameRecvBufferHandler s_bufHandler;
static FNetCliGameRecvGameMgrMsgHandler s_gameMgrMsgHandler;
static long s_perf[kNumPerf];
static std::atomic<long> s_perf[kNumPerf];
/*****************************************************************************
@ -419,14 +419,14 @@ CliGmConn::CliGmConn ()
, seq(0), abandoned(false)
, pingTimer(nil), pingSendTimeMs(0), lastHeardTimeMs(0)
{
AtomicAdd(&s_perf[kPerfConnCount], 1);
++s_perf[kPerfConnCount];
}
//============================================================================
CliGmConn::~CliGmConn () {
if (cli)
NetCliDelete(cli, true);
AtomicAdd(&s_perf[kPerfConnCount], -1);
--s_perf[kPerfConnCount];
}
//============================================================================

View File

@ -188,7 +188,7 @@ static CCritSect s_critsect;
static LISTDECL(CliGkConn, link) s_conns;
static CliGkConn * s_active;
static long s_perf[kNumPerf];
static std::atomic<long> s_perf[kNumPerf];
@ -532,14 +532,14 @@ CliGkConn::CliGkConn ()
{
memset(name, 0, sizeof(name));
AtomicAdd(&s_perf[kPerfConnCount], 1);
++s_perf[kPerfConnCount];
}
//============================================================================
CliGkConn::~CliGkConn () {
if (cli)
NetCliDelete(cli, true);
AtomicAdd(&s_perf[kPerfConnCount], -1);
--s_perf[kPerfConnCount];
}
//===========================================================================

View File

@ -66,7 +66,7 @@ static const unsigned kDefaultTimeoutMs = 5 * 60 * 1000;
static bool s_running;
static CCritSect s_critsect;
static LISTDECL(NetTrans, m_link) s_transactions;
static long s_perf[kNumPerf];
static std::atomic<long> s_perf[kNumPerf];
static unsigned s_timeoutMs = kDefaultTimeoutMs;
@ -127,16 +127,16 @@ NetTrans::NetTrans (ENetProtocol protocol, ETransType transType)
, m_timeoutAtMs(0)
, m_transType(transType)
{
AtomicAdd(&s_perf[kPerfCurrTransactions], 1);
AtomicAdd(&s_perfTransCount[m_transType], 1);
++s_perf[kPerfCurrTransactions];
++s_perfTransCount[m_transType];
// DebugMsg("%s@%p created", s_transTypes[m_transType], this);
}
//============================================================================
NetTrans::~NetTrans () {
ASSERT(!m_link.IsLinked());
AtomicAdd(&s_perfTransCount[m_transType], -1);
AtomicAdd(&s_perf[kPerfCurrTransactions], -1);
--s_perfTransCount[m_transType];
--s_perf[kPerfCurrTransactions];
// DebugMsg("%s@%p destroyed", s_transTypes[m_transType], this);
}