本文整理汇总了C++中CCriticalSection::Leave方法的典型用法代码示例。如果您正苦于以下问题:C++ CCriticalSection::Leave方法的具体用法?C++ CCriticalSection::Leave怎么用?C++ CCriticalSection::Leave使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCriticalSection
的用法示例。
在下文中一共展示了CCriticalSection::Leave方法的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;
}
示例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(¶mArray[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;
}
示例3: OnApplicationRequest_
//.........这里部分代码省略.........
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,
pAppRequestInfo->Parameters.TDI.uDataLen );
//g_dnsRecorder.Record(
// (PROTO_TYPE)pAppRequestInfo->nRequestProtocol,
// (PACKET_DIR)pAppRequestInfo->Parameters.TDI.uPacketDir,
// lip, lport,
// rip, rport,
// pAppRequestInfo->Parameters.TDI.bData,
// pAppRequestInfo->Parameters.TDI.uDataLen );
g_csOutput.Leave();
return S_OK;
}
//获取堆栈模块
sModulePath = "Parents:\n";
if( !GetStackModule( pAppRequestInfo->dwParentModules, NULL, sModulePath, wsExePath ) )
{
//sModulePath = "NoFoundModle";
}
sModulePath += "StackModules:\n";
//获取堆栈模块
if( !GetStackModule( pAppRequestInfo->dwStackModules, pAppRequestInfo->dwStackRetAddr, sModulePath, wsExePath ) )
{
sModulePath = "NoFoundModle";
}
if( pAppRequestInfo->nRequestProtocol == enumPT_LANMAN )
{
string sPath;
ConvertAnsi( pAppRequestInfo->Parameters.LanMan.wsPath, sPath );
sprintf_s(szCmdLine, "fakepop.exe --ptype %s --t %s --pid %d --lan %s --m \n%s",
szRequestProtocol.c_str(),
szRequestType.c_str(),
pAppRequestInfo->dwProcessId,
sPath.c_str(),
sModulePath.c_str()
);
}
else if( pAppRequestInfo->nRequestProtocol == enumPT_HTTP )
示例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;
}