当前位置: 首页>>代码示例>>C++>>正文


C++ CFactory::SetAllocatePolicy方法代码示例

本文整理汇总了C++中CFactory::SetAllocatePolicy方法的典型用法代码示例。如果您正苦于以下问题:C++ CFactory::SetAllocatePolicy方法的具体用法?C++ CFactory::SetAllocatePolicy怎么用?C++ CFactory::SetAllocatePolicy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CFactory的用法示例。


在下文中一共展示了CFactory::SetAllocatePolicy方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: OnInitialize

	virtual bool OnInitialize()
	{
		uint32 nLength;
		const char* sVal;
		CTextAccess oAccess;
		CInitConfigSystem* pConfigSystem = CInitConfigSystem::GetInstance();
		CFiberManager* pFiberManager = CFiberManager::GetInstance();
		uint32 nFiberIdBits=32;
		uint32 nFiberType, nFiberCount;
		int32 nGroupCount=1, nWorkerCount;
		m_pTimerService = CServiceManager::GetInstance()->QueryService("TimerService");
		if(m_pTimerService == NULL)
		{
			FocpLog(FOCP_LOG_ERROR, ("Missing the service 'TimerService'"));
			return false;
		}
		if(pConfigSystem->OpenConfig(oAccess, "FiberService", true))
		{
			oAccess.OpenIdxVal();
			if(oAccess.Query())
			{
				sVal = oAccess.GetVal("FiberIdBits", nLength);
				if(sVal)
				{
					if(sVal[nLength-1])
					{
						FocpLog(FOCP_LOG_ERROR, ("The config 'FiberService.FiberIdBits' is invalid"));
						return false;
					}
					nFiberIdBits = CString::Atoi(sVal);
					if(nFiberIdBits > 32 || nFiberIdBits == 0)
						nFiberIdBits = 32;
				}
				sVal = oAccess.GetVal("GroupCount", nLength);
				if(sVal)
				{
					if(sVal[nLength-1])
					{
						FocpLog(FOCP_LOG_ERROR, ("The config 'FiberService.WorkerCount' is invalid"));
						return false;
					}
					nGroupCount = CString::Atoi(sVal);
					if(nGroupCount <= 0)
					{
						FocpLog(FOCP_LOG_ERROR, ("The config 'FiberService.WorkerCount' is invalid"));
						return false;
					}
				}
			}
		}
		if(pConfigSystem->OpenConfig(oAccess, "FiberConfig", true))
		{
			CFactory* pFactory = CFiberManager::GetFactory();
			oAccess.OpenIdxVal();
			while(oAccess.Query())
			{
				sVal = oAccess.GetVal("FiberType", nLength);
				if(!sVal || sVal[nLength-1])
				{
					FocpLog(FOCP_LOG_ERROR, ("The config 'FiberConfig.FiberType' is invalid"));
					return false;
				}
				nFiberType = CString::Atoi(sVal);
				sVal = oAccess.GetVal("FiberCount", nLength);
				if(!sVal || sVal[nLength-1])
				{
					FocpLog(FOCP_LOG_ERROR, ("The config 'FiberConfig.FiberCount of FiberType[%u]' is invalid", nFiberType));
					return false;
				}
				nFiberCount = CString::Atoi(sVal);
				if(!nFiberCount)
				{
					FocpLog(FOCP_LOG_ERROR, ("The config 'FiberConfig.FiberCount of FiberType[%u]' is invalid", nFiberType));
					return false;
				}
				CAllocatePolicy oPolicy = {nFiberCount,nFiberCount,nFiberCount};
				if(!pFactory->SetAllocatePolicy(nFiberType, oPolicy))
				{
					FocpLog(FOCP_LOG_ERROR, ("SetFiberCapacity(FiberType=%u, FiberCount=%u)' failure", nFiberType, nFiberCount));
					return false;
				}
			}
		}
		pFiberManager->Initialize(nFiberIdBits, nGroupCount);
		if(pConfigSystem->OpenConfig(oAccess, "FiberWorker", true))
		{
			int32 nGroupIdx;
			oAccess.OpenIdxVal();
			while(oAccess.Query())
			{
				sVal = oAccess.GetVal("GroupIdx", nLength);
				if(!sVal || sVal[nLength-1])
				{
					FocpLog(FOCP_LOG_ERROR, ("The config 'FiberWorker.GroupIdx' is invalid"));
					return false;
				}
				nGroupIdx = CString::Atoi(sVal);
				if(nGroupIdx < 0 || nGroupIdx >= nGroupCount)
				{
					FocpLog(FOCP_LOG_ERROR, ("The config 'FiberWorker.GroupIdx' is invalid"));
//.........这里部分代码省略.........
开发者ID:nightstyles,项目名称:focp,代码行数:101,代码来源:FiberService.cpp


注:本文中的CFactory::SetAllocatePolicy方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。