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


C++ CCriticalSection::Enter方法代码示例

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


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

示例1: Sort

STDMETHODIMP CXRecords::Sort(VARIANT key, VARIANT varAsc)
{
	if(!m_pFields)return SetErrorInfo(s_errInit);

	int pos, bAsc;

	int count = m_listRecords->GetCount();

	if(count == 0)
		return S_OK;

	pos = m_pFields->FindField(key);
	if(pos < 0 || pos >= (int)m_pFields->GetCount())
		return DISP_E_BADINDEX;

	bAsc = varGetNumbar(varAsc, 1);

	s_csSort.Enter();
	s_posSort = pos;
	s_bAscSort = bAsc ? 1 : -1;

	qsort(&m_listRecords->GetValue(0), count, sizeof(CXComPtr<CXRecord>), sortProc);

	s_csSort.Leave();

	return S_OK;
}
开发者ID:JimLiu,项目名称:asptools,代码行数:27,代码来源:XRecords.cpp

示例2: ExecuteSimulatedAnnealing

		bool __cdecl ExecuteSimulatedAnnealing(
			__int32 sessionId,
			IGenericStream* inStream,
			IGenericStream* outStream)
		{
			CS.Enter();
			CSessionDataCache::iterator i = sessionDataCache.find(sessionId);
			_ASSERTE(i != sessionDataCache.end());
			CS.Leave();

			TSessionData& sd = i->second;

			__int8 bDirectAccess = false;
			inStream->Read(&bDirectAccess, sizeof(bDirectAccess));


			//here we are not suppose to more than obne simulation in the same loc
			unsigned __int64 locNo = 0;
			inStream->Read(&locNo, sizeof(locNo));
			ASSERT(locNo < sd.m_modelVector.size());
			unsigned __int64 XSize = 0;
			inStream->Read(&XSize, sizeof(XSize));
			ASSERT(XSize < (long)100);

			vector<double> paramArray(XSize);
			for (size_t i = 0; i < XSize; i++)
				inStream->Read(&paramArray[i], sizeof(paramArray[i]));

			//LeaveCriticalSection(&CS);

			CStatisticXY stat;
			sd.m_modelVector[locNo]->GetFValue(paramArray, stat);

			//write outputStream
			outStream->Write(&sessionId, sizeof(sessionId));
			outStream->Write(&locNo, sizeof(locNo));
			outStream->Write(&stat, sizeof(stat));


			return true;
		}
开发者ID:RNCan,项目名称:WeatherBasedSimulationFramework,代码行数:41,代码来源:EntryPoint.cpp

示例3: OnApplicationRequest_

STDMETHODIMP SimpleKfwEvent::OnApplicationRequest_( APP_REQUEST_INFO  *pAppRequestInfo, PULONG pAllow )
{
	DWORD dwResult = 0;
	DWORD dwResponseCode = Pass;
	char szCmdLine[4096] = {0};
	PROCESS_INFORMATION ProcessInfo;
	STARTUPINFOA StartupInfo;
	string szRequestType;
	string szRequestProtocol;
	string sModulePath;
	wstring wsExePath;
	int iret = 0;
	const int DenyCode = 'Deny';
	const int AlwaysDenyCode = 'alDy';
	const int AlwaysPassCode = 'alPs';
	const int PassRecordCode = 'Psrc';
	const int AlwaysPassRecordCode = 'alPr';

	if ( pAppRequestInfo == NULL || pAllow == NULL )
		return E_FAIL;
	
	switch( pAppRequestInfo->nRequestProtocol )
	{
	case enumPT_TCP:
		szRequestProtocol = "TCP";
		break;
	case enumPT_UDP:
		szRequestProtocol = "UDP";
		break;
	case enumPT_RAWIP:
		szRequestProtocol = "RAWIP";
		break;
	case enumPT_LANMAN:
		szRequestProtocol = "LAN";
		break;
	case enumPT_HTTP:
		szRequestProtocol = "HTTP";
		break;
	case enumPT_FILE_MON:
		szRequestProtocol = "FILE_MON";
		break;
	}

	switch( pAppRequestInfo->nRequestType )
	{
	case ART_Connect:
		szRequestType = "ART_Connect";	
		break;
	case ART_Listen:
		szRequestType = "ART_Listen";	
		break;
	case ART_Accept:
		szRequestType = "ART_Accept";	
		break;
	case ART_Bind:
		szRequestType = "ART_Bind";	
		break;
	case ART_Close:
		szRequestType = "ART_Close";	
		break;
	case ART_Create:
		szRequestType = "ART_Create";	
		break;
	case ART_TrustUrl:
		szRequestType = "ART_TrustUrl";
		break;
	case ART_FileChanged:
		szRequestType = "ART_FileChanged";
		break;
	case ART_PacketRecord:
		szRequestType = "ART_PacketRecord";
		break;
	default:
		szRequestType = "Unknown Request";
	}
		

	if( pAppRequestInfo->nRequestType == ART_PacketRecord )
	{
		DWORD lip = pAppRequestInfo->Parameters.TDI.dwLocalAddress;
		SHORT lport = pAppRequestInfo->Parameters.TDI.wLocalPort;
		
		DWORD rip = pAppRequestInfo->Parameters.TDI.dwRemoteAddress;
		SHORT rport = pAppRequestInfo->Parameters.TDI.wRemotePort;
		g_csOutput.Enter();
		printf( "-------------------------------------\n" );
		printf( "Direction:%s\n", pAppRequestInfo->Parameters.TDI.uPacketDir == enumPD_Send ? "Send" : "Recv"  );
		printf( "ART_PacketRecord: PackSize:%d\n", pAppRequestInfo->Parameters.TDI.uDataLen );
		printf( "LocalAddr:%02d.%02d.%02d.%02d:%d\n", 
			*(((BYTE*)&lip)+0), *(((BYTE*)&lip)+1), *(((BYTE*)&lip)+2), *(((BYTE*)&lip)+3), lport );
		printf( "RemoteAddr:%02d.%02d.%02d.%02d:%d\n", 
			*(((BYTE*)&rip)+0), *(((BYTE*)&rip)+1), *(((BYTE*)&rip)+2), *(((BYTE*)&rip)+3), rport );
		
		
		g_pcapRecorder.Record( TEXT("c:\\dns.pcap"), 
				(PROTO_TYPE)pAppRequestInfo->nRequestProtocol,
				(PACKET_DIR)pAppRequestInfo->Parameters.TDI.uPacketDir,
				lip, lport,
				rip, rport,
				pAppRequestInfo->Parameters.TDI.bData,
//.........这里部分代码省略.........
开发者ID:dreamsxin,项目名称:PcManager,代码行数:101,代码来源:SimpleKfwEvent.cpp

示例4: BeginSession

	ERMsg BeginSession(IAgent* agent, __int32 sessionId, DWORD hxGridSessionId, IGenericStream* globalDataStream = NULL)
	{
		ERMsg msg;
		//EnterCriticalSection(&sessionDataCache.m_CS);
		CS.Enter();

		CSessionDataCache::iterator i = sessionDataCache.find(sessionId);

		if (i == sessionDataCache.end())
		{
			//----------- read global data -------------
			//CStdString tmp;
			//tmp.Format("Before init\nsessionId = %d\nhxGridSessionId = %d",sessionId, hxGridSessionId);
			//MessageBox(NULL, (LPCTSTR)tmp, "BeginSession", MB_OK);   
			if (globalDataStream == NULL)
			{
				ASSERT(agent);
				HRESULT rz = agent->GetData(hxGridSessionId, SIMULATED_ANNEALING_DATA_DESCRIPTOR, &globalDataStream);

				if (rz != S_OK)
				{
					CS.Leave();

					msg.ajoute(string("ERROR: agent->GetData from ") + SIMULATED_ANNEALING_DATA_DESCRIPTOR + " failed");
					return msg;
				}
			}

			//insert a new session
			sessionDataCache.insert(std::make_pair(sessionId, TSessionData()));
			i = sessionDataCache.find(sessionId);
			ASSERT(i != sessionDataCache.end());


			TSessionData& sd = i->second;

			istringstream iStream(string((char*)globalDataStream->GetBasePointer(), globalDataStream->GetLength()));
			msg = sd.m_modelVector.ReadStream(iStream);
			if (!msg)
				return msg;

			//free global stream. No longer need for this session
			if (agent)
			{
				//release global stream 
				globalDataStream->Release();
				agent->FreeCachedData(hxGridSessionId, SIMULATED_ANNEALING_DATA_DESCRIPTOR);

				//set agent on model
				for (CSimulatedAnnealingVector::iterator it = sd.m_modelVector.begin(); it != sd.m_modelVector.end(); it++)
				{
					(*it)->m_pAgent = agent;
					(*it)->m_hxGridSessionID = hxGridSessionId;
				}
			}
		}

		CS.Leave();

		return msg;
	}
开发者ID:RNCan,项目名称:WeatherBasedSimulationFramework,代码行数:61,代码来源:EntryPoint.cpp


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