Browse Source

pnUtRef started at zero refs instead of one, and this is simpler

than finding and removing all the extra Ref() calls.
Michael Hansen 11 years ago
parent
commit
23a071860e
  1. 5
      Sources/Plasma/CoreLib/hsRefCnt.h
  2. 14
      Sources/Plasma/NucleusLib/pnAsyncCoreExe/Private/Win32/pnAceW32Thread.cpp
  3. 2
      Sources/Plasma/NucleusLib/pnNetCli/pnNcChannel.cpp
  4. 2
      Sources/Plasma/NucleusLib/pnNetProtocol/Private/pnNpCommon.cpp
  5. 2
      Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglAuth.cpp
  6. 3
      Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglFile.cpp
  7. 3
      Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglGame.cpp
  8. 2
      Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglGateKeeper.cpp
  9. 3
      Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglTrans.cpp

5
Sources/Plasma/CoreLib/hsRefCnt.h

@ -47,8 +47,9 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
class hsRefCnt {
private:
int fRefCnt;
public:
hsRefCnt() : fRefCnt(1) {}
hsRefCnt(int initRefs = 1) : fRefCnt(initRefs) {}
virtual ~hsRefCnt();
inline int RefCnt() const { return fRefCnt; }
@ -75,7 +76,7 @@ private:
std::atomic<int> fRefCnt;
public:
hsAtomicRefCnt() : fRefCnt(1) { }
hsAtomicRefCnt(int initRefs = 1) : fRefCnt(initRefs) { }
virtual ~hsAtomicRefCnt();
inline int RefCnt() const { return fRefCnt; }

14
Sources/Plasma/NucleusLib/pnAsyncCoreExe/Private/Win32/pnAceW32Thread.cpp

@ -48,6 +48,8 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "../../Pch.h"
#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;
AsyncThreadTaskList ();
~AsyncThreadTaskList ();
@ -79,7 +81,7 @@ static HANDLE s_taskPort;
//===========================================================================
AsyncThreadTaskList::AsyncThreadTaskList ()
: error(kNetSuccess)
: hsAtomicRefCnt(0), error(kNetSuccess)
{
PerfAddCounter(kAsyncPerfThreadTaskListCount, 1);
}
@ -139,7 +141,7 @@ static unsigned THREADCALL ThreadTaskProc (AsyncThread * thread) {
if (task) {
task->callback(task->param, task->taskList->error);
task->taskList->DecRef("task");
task->taskList->Ref("task");
delete task;
}
}
@ -227,7 +229,7 @@ void AsyncThreadTaskSetThreadCount (unsigned threads) {
AsyncThreadTaskList * AsyncThreadTaskListCreate () {
ASSERT(s_taskPort);
AsyncThreadTaskList * taskList = new AsyncThreadTaskList;
taskList->IncRef("TaskList");
taskList->Ref("TaskList");
return taskList;
}
@ -241,7 +243,7 @@ void AsyncThreadTaskListDestroy (
ASSERT(!taskList->error);
taskList->error = error;
taskList->DecRef(); // REF:TaskList
taskList->UnRef(); // REF:TaskList
}
//===========================================================================
@ -263,7 +265,7 @@ void AsyncThreadTaskAdd (
task->callback = callback;
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
taskList->IncRef("Task");
taskList->Ref("Task");
PostQueuedCompletionStatus(s_taskPort, 0, (DWORD) task, NULL);
}

2
Sources/Plasma/NucleusLib/pnNetCli/pnNcChannel.cpp

@ -74,6 +74,8 @@ private:
};
struct NetMsgChannel : hsAtomicRefCnt {
NetMsgChannel() : hsAtomicRefCnt(0) { }
uint32_t m_protocol;
bool m_server;

2
Sources/Plasma/NucleusLib/pnNetProtocol/Private/pnNpCommon.cpp

@ -315,7 +315,7 @@ void NetVaultNode::DeallocNodeFields () {
//============================================================================
NetVaultNode::NetVaultNode ()
: fieldFlags(0), dirtyFlags(0)
: hsAtomicRefCnt(0), fieldFlags(0), dirtyFlags(0)
, nodeId(0), createTime(0), modifyTime(0)
, createAgeName(nil), creatorId(0)
, nodeType(0)

2
Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglAuth.cpp

@ -1589,7 +1589,7 @@ static unsigned CliAuConnPingTimerProc (void * param) {
//============================================================================
CliAuConn::CliAuConn ()
: reconnectTimer(nil), reconnectStartMs(0)
: hsAtomicRefCnt(0), reconnectTimer(nil), reconnectStartMs(0)
, pingTimer(nil), pingSendTimeMs(0), lastHeardTimeMs(0)
, sock(nil), cli(nil), seq(0), serverChallenge(0)
, cancelId(nil), abandoned(false)

3
Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglFile.cpp

@ -581,7 +581,8 @@ static void AsyncLookupCallback (
//============================================================================
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)
, numImmediateDisconnects(0), numFailedConnects(0)
, pingTimer(nil), pingSendTimeMs(0), lastHeardTimeMs(0)

3
Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglGame.cpp

@ -415,7 +415,8 @@ static unsigned CliGmConnPingTimerProc (void * param) {
//============================================================================
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)
{
AtomicAdd(&s_perf[kPerfConnCount], 1);

2
Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglGateKeeper.cpp

@ -525,7 +525,7 @@ static unsigned CliGkConnPingTimerProc (void * param) {
//============================================================================
CliGkConn::CliGkConn ()
: reconnectTimer(nil), reconnectStartMs(0)
: hsAtomicRefCnt(0), reconnectTimer(nil), reconnectStartMs(0)
, pingTimer(nil), pingSendTimeMs(0), lastHeardTimeMs(0)
, sock(nil), cli(nil), seq(0), serverChallenge(0)
, cancelId(nil), abandoned(false)

3
Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglTrans.cpp

@ -117,7 +117,8 @@ static void CancelTrans_CS (NetTrans * trans, ENetError error) {
//============================================================================
NetTrans::NetTrans (ENetProtocol protocol, ETransType transType)
: m_state(kTransStateWaitServerConnect)
: hsAtomicRefCnt(0)
, m_state(kTransStateWaitServerConnect)
, m_result(kNetPending)
, m_transId(0)
, m_connId(0)

Loading…
Cancel
Save