Пример #1
0
	Bool CApp::PostMsg(const XIDVector& vXID, CMsg* pMsg)
	{
		if (pMsg && vXID.size())
		{
			Int32 iCount = GetThreadNum();
			Assert(iCount > 0);
			map<Int32, XIDVector> mThreadXid;
		
			for(Size_t i=0;i<vXID.size();i++)
			{
				Int32 iIdx = vXID[i].Id % iCount;
				if (mThreadXid.find(iIdx) == mThreadXid.end())
					mThreadXid[iIdx] = XIDVector();
				
				mThreadXid[iIdx].push_back(vXID[i]);
			}

			map<Int32, XIDVector>::iterator it = mThreadXid.begin();
			for (;it!=mThreadXid.end();it++)
			{
				CApp_MsgTask* pTask = new CApp_MsgTask(it->second, pMsg);
				CScope::ObjPtr scope(pTask);
				PostAppTask(pTask, it->first);
			}
		}

		g_MsgManager->FreeMsg(pMsg);
		return true;
	}
Пример #2
0
		CApp_MsgTask(const XIDVector& vXid, CMsg* pMsg) : m_pMsg(pMsg)
		{
			for (Size_t i=0;i<vXid.size();i++)
			{
				m_vXid.push_back(vXid[i]);
			}
		};
Пример #3
0
		CApp_TickTask(const XIDVector& vXid)
		{
			for (Size_t i=0;i<vXid.size();i++)
			{
				m_vXid.push_back(vXid[i]);
			}
		};
Пример #4
0
		virtual void ResetXids(const XIDVector& vXid)
		{
			m_vXid.clear();
			for (Size_t i=0;i<vXid.size();i++)
			{
				m_vXid.push_back(vXid[i]);
			}
		}
Пример #5
0
	Bool CApp::PostTick(const XIDVector& vXID)
	{
		if (vXID.size())
		{
			Int32 iCount = GetThreadNum();
			Assert(iCount > 0);
			map<Int32, XIDVector> mThreadXid;

			for(Size_t i=0;i<vXID.size();i++)
			{
				Int32 iIdx = vXID[i].Id % iCount;
				if (mThreadXid.find(iIdx) == mThreadXid.end())
					mThreadXid[iIdx] = XIDVector();

				mThreadXid[iIdx].push_back(vXID[i]);
			}

			map<Int32, XIDVector>::iterator it = mThreadXid.begin();
			for (;it!=mThreadXid.end();it++)
			{
				static map<Int32, CApp_TickTask> mTickTask;

				CApp_TickTask* pTask = 0;
				map<Int32, CApp_TickTask>::iterator tit = mTickTask.find(it->first);
				if (tit == mTickTask.end())
				{
					mTickTask.insert(std::make_pair(it->first, CApp_TickTask(it->second)));
					pTask = &mTickTask.find(it->first)->second;
				}
				else
				{
					pTask = &tit->second;
					pTask->ResetXids(it->second);
				}

				if (pTask)
				{
					pTask->AddRef();
					PostAppTask(pTask, it->first);
				}				
			}
		}

		return true;
	}
Пример #6
0
	Bool HawkAppFrame::BroadcastMsg(ObjMan* pObjMan, HawkMsg* pMsg)
	{
		if (pObjMan && pMsg)
		{
			XIDVector vXID;
			pObjMan->CollectObjKey(vXID);

			if (vXID.size())
				PostMsg(vXID, pMsg);

			return true;
		}		
		return false;
	}