Skip to content

Commit fe9c957

Browse files
committed
继续完善watcher
1 parent 08f9bce commit fe9c957

5 files changed

Lines changed: 30 additions & 9 deletions

File tree

‎kbe/src/build/common.mak‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,10 @@ KBE_INCLUDES += -I $(KBE_ROOT)/kbe/src/lib/third_party/tinyxml
152152
LDLIBS += $(addprefix -l, $(MY_LIBS))
153153
LDLIBS += -lm
154154

155+
ifndef DISABLE_WATCHERS
156+
CPPFLAGS += ENABLE_WATCHERS
157+
#endif
158+
155159
ifdef USE_PYTHON
156160

157161
USE_KBE_PYTHON = 1

‎kbe/src/lib/server/server90.vcproj‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
Name="VCCLCompilerTool"
4343
Optimization="0"
4444
AdditionalIncludeDirectories="../../lib/python/PC;../../lib/python/Include;../../lib;../../common;../../lib/third_party/g3dlite;../../lib/third_party/log4cxx/include;../../lib/third_party;../../lib/third_party/openssl/include"
45-
PreprocessorDefinitions="WIN32;_DEBUG;_LIB;CODE_INLINE;KBE_USE_ASSERTS;LOG4CXX_STATIC;KBE_SERVER"
45+
PreprocessorDefinitions="WIN32;_DEBUG;_LIB;CODE_INLINE;ENABLE_WATCHERS;KBE_USE_ASSERTS;LOG4CXX_STATIC;KBE_SERVER"
4646
MinimalRebuild="true"
4747
BasicRuntimeChecks="3"
4848
RuntimeLibrary="1"
@@ -107,7 +107,7 @@
107107
Optimization="2"
108108
EnableIntrinsicFunctions="true"
109109
AdditionalIncludeDirectories="../../lib/python/PC;../../lib/python/Include;../../lib;../../common;../../lib/third_party/g3dlite;../../lib/third_party/log4cxx/include;../../lib/third_party;../../lib/third_party/openssl/include"
110-
PreprocessorDefinitions="WIN32;NDEBUG;_LIB;CODE_INLINE;KBE_USE_ASSERTS;LOG4CXX_STATIC;KBE_SERVER"
110+
PreprocessorDefinitions="WIN32;NDEBUG;_LIB;CODE_INLINE;ENABLE_WATCHERS;KBE_USE_ASSERTS;LOG4CXX_STATIC;KBE_SERVER"
111111
RuntimeLibrary="0"
112112
EnableFunctionLevelLinking="true"
113113
UsePrecompiledHeader="0"

‎kbe/src/lib/server/serverapp.cpp‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,13 @@ bool ServerApp::initialize()
112112
Componentbridge::getSingleton().getComponents().pHandler(this);
113113
this->getMainDispatcher().addFrequentTask(&Componentbridge::getSingleton());
114114

115-
return initializeEnd() && initializeWatcher();
115+
bool ret = initializeEnd();
116+
117+
#if ENABLE_WATCHERS
118+
return ret && initializeWatcher();
119+
#else
120+
return ret;
121+
#endif
116122
}
117123

118124
//-------------------------------------------------------------------------------------

‎kbe/src/server/baseapp/baseapp.cpp‎

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ Baseapp::Baseapp(Mercury::EventDispatcher& dispatcher,
114114
pendingLoginMgr_(ninterface),
115115
forward_messagebuffer_(ninterface),
116116
pBackupSender_(),
117-
proxicesCount_(0)
117+
numProxices_(0)
118118
{
119119
KBEngine::Mercury::MessageHandlers::pMainMessageHandlers = &BaseappInterface::messageHandlers;
120120
}
@@ -124,6 +124,15 @@ Baseapp::~Baseapp()
124124
{
125125
}
126126

127+
//-------------------------------------------------------------------------------------
128+
bool Baseapp::initializeWatcher()
129+
{
130+
WATCH_OBJECT("numProxices", this, &Baseapp::numProxices);
131+
WATCH_OBJECT("load", this, &Baseapp::getLoad);
132+
133+
return EntityApp<Base>::initializeWatcher();
134+
}
135+
127136
//-------------------------------------------------------------------------------------
128137
bool Baseapp::installPyModules()
129138
{
@@ -295,7 +304,7 @@ void Baseapp::updateLoad()
295304
Mercury::Bundle* pBundle = Mercury::Bundle::ObjPool().createObject();
296305
(*pBundle).newMessage(BaseappmgrInterface::updateBaseapp);
297306
BaseappmgrInterface::updateBaseappArgs4::staticAddToBundle((*pBundle),
298-
componentID_, pEntities_->getEntities().size() - proxicesCount(), proxicesCount(), this->getLoad());
307+
componentID_, pEntities_->getEntities().size() - numProxices(), numProxices(), this->getLoad());
299308

300309
(*pBundle).send(this->getNetworkInterface(), pChannel);
301310
Mercury::Bundle::ObjPool().reclaimObject(pBundle);

‎kbe/src/server/baseapp/baseapp.hpp‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@ class Baseapp : public EntityApp<Base>,
8686
bool initializeEnd();
8787
void finalise();
8888

89+
virtual bool initializeWatcher();
90+
8991
float getLoad()const { return load_; }
9092

9193
void updateLoad();
@@ -295,17 +297,17 @@ class Baseapp : public EntityApp<Base>,
295297
/**
296298
增加proxices计数
297299
*/
298-
void incProxicesCount(){ ++proxicesCount_; }
300+
void incProxicesCount(){ ++numProxices_; }
299301

300302
/**
301303
减少proxices计数
302304
*/
303-
void decProxicesCount(){ --proxicesCount_; }
305+
void decProxicesCount(){ --numProxices_; }
304306

305307
/**
306308
获得proxices计数
307309
*/
308-
int32 proxicesCount()const{ return proxicesCount_; }
310+
int32 numProxices()const{ return numProxices_; }
309311

310312
protected:
311313
TimerHandle loopCheckTimerHandle_;
@@ -325,7 +327,7 @@ class Baseapp : public EntityApp<Base>,
325327

326328
static uint64 _g_lastTimestamp;
327329

328-
int32 proxicesCount_;
330+
int32 numProxices_;
329331

330332
};
331333

0 commit comments

Comments
 (0)