mirror of
https://foundry.openuru.org/gitblit/r/CWE-ou-minkata.git
synced 2025-07-17 18:59:09 +00:00
pnUtRef started at zero refs instead of one, and this is simpler
than finding and removing all the extra Ref() calls.
This commit is contained in:
@ -47,8 +47,9 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
|||||||
class hsRefCnt {
|
class hsRefCnt {
|
||||||
private:
|
private:
|
||||||
int fRefCnt;
|
int fRefCnt;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
hsRefCnt() : fRefCnt(1) {}
|
hsRefCnt(int initRefs = 1) : fRefCnt(initRefs) {}
|
||||||
virtual ~hsRefCnt();
|
virtual ~hsRefCnt();
|
||||||
|
|
||||||
inline int RefCnt() const { return fRefCnt; }
|
inline int RefCnt() const { return fRefCnt; }
|
||||||
@ -75,7 +76,7 @@ private:
|
|||||||
std::atomic<int> fRefCnt;
|
std::atomic<int> fRefCnt;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
hsAtomicRefCnt() : fRefCnt(1) { }
|
hsAtomicRefCnt(int initRefs = 1) : fRefCnt(initRefs) { }
|
||||||
virtual ~hsAtomicRefCnt();
|
virtual ~hsAtomicRefCnt();
|
||||||
|
|
||||||
inline int RefCnt() const { return fRefCnt; }
|
inline int RefCnt() const { return fRefCnt; }
|
||||||
|
@ -48,6 +48,8 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
|||||||
#include "../../Pch.h"
|
#include "../../Pch.h"
|
||||||
#pragma hdrstop
|
#pragma hdrstop
|
||||||
|
|
||||||
|
#include "hsRefCnt.h"
|
||||||
|
|
||||||
|
|
||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
*
|
*
|
||||||
@ -55,7 +57,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
|||||||
*
|
*
|
||||||
***/
|
***/
|
||||||
|
|
||||||
struct AsyncThreadTaskList : AtomicRef {
|
struct AsyncThreadTaskList : hsAtomicRefCnt {
|
||||||
ENetError error;
|
ENetError error;
|
||||||
AsyncThreadTaskList ();
|
AsyncThreadTaskList ();
|
||||||
~AsyncThreadTaskList ();
|
~AsyncThreadTaskList ();
|
||||||
@ -79,7 +81,7 @@ static HANDLE s_taskPort;
|
|||||||
|
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
AsyncThreadTaskList::AsyncThreadTaskList ()
|
AsyncThreadTaskList::AsyncThreadTaskList ()
|
||||||
: error(kNetSuccess)
|
: hsAtomicRefCnt(0), error(kNetSuccess)
|
||||||
{
|
{
|
||||||
PerfAddCounter(kAsyncPerfThreadTaskListCount, 1);
|
PerfAddCounter(kAsyncPerfThreadTaskListCount, 1);
|
||||||
}
|
}
|
||||||
@ -139,7 +141,7 @@ static unsigned THREADCALL ThreadTaskProc (AsyncThread * thread) {
|
|||||||
if (task) {
|
if (task) {
|
||||||
task->callback(task->param, task->taskList->error);
|
task->callback(task->param, task->taskList->error);
|
||||||
|
|
||||||
task->taskList->DecRef("task");
|
task->taskList->Ref("task");
|
||||||
delete task;
|
delete task;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -227,7 +229,7 @@ void AsyncThreadTaskSetThreadCount (unsigned threads) {
|
|||||||
AsyncThreadTaskList * AsyncThreadTaskListCreate () {
|
AsyncThreadTaskList * AsyncThreadTaskListCreate () {
|
||||||
ASSERT(s_taskPort);
|
ASSERT(s_taskPort);
|
||||||
AsyncThreadTaskList * taskList = new AsyncThreadTaskList;
|
AsyncThreadTaskList * taskList = new AsyncThreadTaskList;
|
||||||
taskList->IncRef("TaskList");
|
taskList->Ref("TaskList");
|
||||||
return taskList;
|
return taskList;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -241,7 +243,7 @@ void AsyncThreadTaskListDestroy (
|
|||||||
ASSERT(!taskList->error);
|
ASSERT(!taskList->error);
|
||||||
|
|
||||||
taskList->error = error;
|
taskList->error = error;
|
||||||
taskList->DecRef(); // REF:TaskList
|
taskList->UnRef(); // REF:TaskList
|
||||||
}
|
}
|
||||||
|
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
@ -263,7 +265,7 @@ void AsyncThreadTaskAdd (
|
|||||||
task->callback = callback;
|
task->callback = callback;
|
||||||
task->param = param;
|
task->param = param;
|
||||||
StrCopy(task->debugStr, debugStr, arrsize(task->debugStr)); // this will be sent with the deadlock checker email if this thread exceeds time set in plServer.ini
|
StrCopy(task->debugStr, debugStr, arrsize(task->debugStr)); // this will be sent with the deadlock checker email if this thread exceeds time set in plServer.ini
|
||||||
taskList->IncRef("Task");
|
taskList->Ref("Task");
|
||||||
|
|
||||||
PostQueuedCompletionStatus(s_taskPort, 0, (DWORD) task, NULL);
|
PostQueuedCompletionStatus(s_taskPort, 0, (DWORD) task, NULL);
|
||||||
}
|
}
|
||||||
|
@ -74,6 +74,8 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct NetMsgChannel : hsAtomicRefCnt {
|
struct NetMsgChannel : hsAtomicRefCnt {
|
||||||
|
NetMsgChannel() : hsAtomicRefCnt(0) { }
|
||||||
|
|
||||||
uint32_t m_protocol;
|
uint32_t m_protocol;
|
||||||
bool m_server;
|
bool m_server;
|
||||||
|
|
||||||
|
@ -315,7 +315,7 @@ void NetVaultNode::DeallocNodeFields () {
|
|||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
NetVaultNode::NetVaultNode ()
|
NetVaultNode::NetVaultNode ()
|
||||||
: fieldFlags(0), dirtyFlags(0)
|
: hsAtomicRefCnt(0), fieldFlags(0), dirtyFlags(0)
|
||||||
, nodeId(0), createTime(0), modifyTime(0)
|
, nodeId(0), createTime(0), modifyTime(0)
|
||||||
, createAgeName(nil), creatorId(0)
|
, createAgeName(nil), creatorId(0)
|
||||||
, nodeType(0)
|
, nodeType(0)
|
||||||
|
@ -1589,7 +1589,7 @@ static unsigned CliAuConnPingTimerProc (void * param) {
|
|||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
CliAuConn::CliAuConn ()
|
CliAuConn::CliAuConn ()
|
||||||
: reconnectTimer(nil), reconnectStartMs(0)
|
: hsAtomicRefCnt(0), reconnectTimer(nil), reconnectStartMs(0)
|
||||||
, pingTimer(nil), pingSendTimeMs(0), lastHeardTimeMs(0)
|
, pingTimer(nil), pingSendTimeMs(0), lastHeardTimeMs(0)
|
||||||
, sock(nil), cli(nil), seq(0), serverChallenge(0)
|
, sock(nil), cli(nil), seq(0), serverChallenge(0)
|
||||||
, cancelId(nil), abandoned(false)
|
, cancelId(nil), abandoned(false)
|
||||||
|
@ -581,7 +581,8 @@ static void AsyncLookupCallback (
|
|||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
CliFileConn::CliFileConn ()
|
CliFileConn::CliFileConn ()
|
||||||
: sock(nil), seq(0), cancelId(nil), abandoned(false), buildId(0), serverType(0)
|
: hsAtomicRefCnt(0), sock(nil), seq(0), cancelId(nil), abandoned(false)
|
||||||
|
, buildId(0), serverType(0)
|
||||||
, reconnectTimer(nil), reconnectStartMs(0), connectStartMs(0)
|
, reconnectTimer(nil), reconnectStartMs(0), connectStartMs(0)
|
||||||
, numImmediateDisconnects(0), numFailedConnects(0)
|
, numImmediateDisconnects(0), numFailedConnects(0)
|
||||||
, pingTimer(nil), pingSendTimeMs(0), lastHeardTimeMs(0)
|
, pingTimer(nil), pingSendTimeMs(0), lastHeardTimeMs(0)
|
||||||
|
@ -415,7 +415,8 @@ static unsigned CliGmConnPingTimerProc (void * param) {
|
|||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
CliGmConn::CliGmConn ()
|
CliGmConn::CliGmConn ()
|
||||||
: sock(nil), cancelId(nil), cli(nil), seq(0), abandoned(false)
|
: hsAtomicRefCnt(0), sock(nil), cancelId(nil), cli(nil)
|
||||||
|
, seq(0), abandoned(false)
|
||||||
, pingTimer(nil), pingSendTimeMs(0), lastHeardTimeMs(0)
|
, pingTimer(nil), pingSendTimeMs(0), lastHeardTimeMs(0)
|
||||||
{
|
{
|
||||||
AtomicAdd(&s_perf[kPerfConnCount], 1);
|
AtomicAdd(&s_perf[kPerfConnCount], 1);
|
||||||
|
@ -525,7 +525,7 @@ static unsigned CliGkConnPingTimerProc (void * param) {
|
|||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
CliGkConn::CliGkConn ()
|
CliGkConn::CliGkConn ()
|
||||||
: reconnectTimer(nil), reconnectStartMs(0)
|
: hsAtomicRefCnt(0), reconnectTimer(nil), reconnectStartMs(0)
|
||||||
, pingTimer(nil), pingSendTimeMs(0), lastHeardTimeMs(0)
|
, pingTimer(nil), pingSendTimeMs(0), lastHeardTimeMs(0)
|
||||||
, sock(nil), cli(nil), seq(0), serverChallenge(0)
|
, sock(nil), cli(nil), seq(0), serverChallenge(0)
|
||||||
, cancelId(nil), abandoned(false)
|
, cancelId(nil), abandoned(false)
|
||||||
|
@ -117,7 +117,8 @@ static void CancelTrans_CS (NetTrans * trans, ENetError error) {
|
|||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
NetTrans::NetTrans (ENetProtocol protocol, ETransType transType)
|
NetTrans::NetTrans (ENetProtocol protocol, ETransType transType)
|
||||||
: m_state(kTransStateWaitServerConnect)
|
: hsAtomicRefCnt(0)
|
||||||
|
, m_state(kTransStateWaitServerConnect)
|
||||||
, m_result(kNetPending)
|
, m_result(kNetPending)
|
||||||
, m_transId(0)
|
, m_transId(0)
|
||||||
, m_connId(0)
|
, m_connId(0)
|
||||||
|
Reference in New Issue
Block a user