本文整理汇总了C++中CCriticalSection类的典型用法代码示例。如果您正苦于以下问题:C++ CCriticalSection类的具体用法?C++ CCriticalSection怎么用?C++ CCriticalSection使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CCriticalSection类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OnObjmngProperties
void CDlgObjectManager::OnObjmngProperties()
{
if(!m_hI) return;
CCriticalSection cs;
cs.Lock();
CMyObject* pObj;
pObj = FindObj(m_hI);
if(pObj && m_pDoc) {
pObj->Properties();
m_tree.SetItemText(m_hI, pObj->GetIdName());
if(m_pDoc) {
m_pDoc->SetModifiedFlag();
if( pObj->IsKindOf(RUNTIME_CLASS( CImgReferenced )) )
m_pDoc->UpdateAllViews(NULL, UPDATE_BITMAP_CAHNGED);
else if( pObj->IsKindOf(RUNTIME_CLASS(CGridObj)) )
m_pDoc->UpdateAllViews(NULL, UPDATE_LEADHRZ_CAHNGED);
else if( pObj->IsKindOf(RUNTIME_CLASS(CData3D)) )
m_pDoc->UpdateAllViews(NULL, UPDATE_DATA3D_CHANGED);
else
m_pDoc->UpdateAllViews(NULL);
m_hI = NULL;
}
return;
}
CBody* pBd;
pBd = (CBody*) FindBody(m_hI);
if(pBd && m_pDoc) {
pBd->Properties();
m_tree.SetItemText( m_hI, pBd->GetStrIdName() );
m_hI = NULL;
}
}
示例2: CManagerPool
CManagerPool &CManagerPool::GetInitInstance()
{
CCriticalSection Mutex;
if(m_PtrInstance == NULL)
{
//mutex.Lock();
Mutex.Lock();
m_PtrInstance = new CManagerPool();
Mutex.Unlock();
}
return *m_PtrInstance;
}
示例3: NewGUI_DoModal
INT_PTR NewGUI_DoModal(CDialog* pDlg)
{
if(pDlg == NULL) { ASSERT(FALSE); return IDCANCEL; }
CPwSafeDlg* pRootDlg = (CPwSafeDlg*)KPMI_GetMainDialog();
ASSERT(pRootDlg != NULL);
VERIFY(g_csDoModalRoot.Lock() != FALSE);
if(pRootDlg != NULL)
{
pRootDlg->NotifyUserActivity();
pRootDlg->_SetDisplayDialog(true);
}
VERIFY(CGlobalWindowManager::AddDialog(pDlg) == S_OK);
VERIFY(g_csDoModalRoot.Unlock() != FALSE);
const INT_PTR r = pDlg->DoModal();
VERIFY(g_csDoModalRoot.Lock() != FALSE);
VERIFY(CGlobalWindowManager::RemoveDialog(pDlg) == S_OK);
if(pRootDlg != NULL)
{
pRootDlg->NotifyUserActivity();
pRootDlg->_SetDisplayDialog(false);
}
VERIFY(g_csDoModalRoot.Unlock() != FALSE);
return r;
}
示例4: AddErrorMessenger
void LogManager::AddErrorMessenger(Logger::ErrorMessenger* messenger)
{
m_CritSection.Lock();
S3D_ASSERT(messenger);
m_errorMessengers.push_back(messenger);
m_CritSection.Unlock();
}
示例5: recv
unsigned int __stdcall Thread_RecvMsg(void *data)
{
//int nNetTimeout = 30000;
//setsockopt(sockClient,SOL_SOCKET,SO_RCVTIMEO,(char*)&nNetTimeout,sizeof(int));
while(1)
{
int nRet = recv(sockClient,(char*)recvBuf,RECV_BUF_LEN,0);
if((nRet == SOCKET_ERROR)|| (nRet == 0))
{
trySetConnectSocket(true);
critical_section.Lock();
if(exit_flag)
{
critical_section.Unlock();
//shutdown(sockClient,SD_RECEIVE);
shutdown(sockClient,SD_BOTH);
closesocket(sockClient);
return -1;
}
critical_section.Unlock();
Sleep(2000);
}
}
}
示例6: serializeGrantDB
void serializeGrantDB(string filename){
LogPrintf(" Serialize Grant Info Database: Current Grant Database Block Height: %ld\n",grantDatabaseBlockHeight);
ofstream grantdb;
grantdb.open (filename.c_str(), ios::trunc);
//grantDatabaseBlockHeight
grantdb << grantDatabaseBlockHeight << "\n";
//Balances
grantdb << balances.size()<< "\n";
for(it=balances.begin(); it!=balances.end(); ++it){
grantdb << it->first << "\n" << it->second<< "\n";
}
//votingPreferences
for(int i=0;i<numberOfOffices;i++){
grantdb << votingPreferences[i].size()<< "\n";
for(vpit=votingPreferences[i].begin(); vpit!=votingPreferences[i].end(); ++vpit){
grantdb << vpit->first << "\n";
grantdb << vpit->second.size() << "\n";
for(it2=vpit->second.begin();it2!=vpit->second.end();++it2){
grantdb << it2->first << "\n" << it2->second<< "\n";
}
}
}
grantdb.flush();
grantdb.close();
}
示例7: StaticGetTotalBytesSent
long long EHS::StaticGetTotalBytesSent ( void )
{
ms_StatsCS.Lock();
long long llResult = ms_HttpTotalBytesSent;
ms_StatsCS.Unlock();
return llResult;
}
示例8: GetTickCountInternal
//
// Retrieves the number of milliseconds that have elapsed since some arbitrary point in time.
//
// GetTickCount64() exists on Vista and up and is like GetTickCount() except it returns
// an __int64 and will effectively never wrap. This is an emulated version for XP and down.
// Note: Wrap around issue is only defeated if the gap between calls is less than 24 days.
//
long long SharedUtil::GetTickCount64_ ( void )
{
ms_criticalSection.Lock ();
static long long llCurrent = ( GetTickCountInternal () % 300000 + 200000 );
static uint uiWas = GetTickCountInternal();
uint uiNow = GetTickCountInternal();
uint uiDelta = uiNow - uiWas;
uiWas = uiNow;
// Ensure delta is not negative
if ( uiDelta > 0x80000000 )
uiDelta = 0;
// Or greater than 600 seconds
if ( uiDelta > 600 * 1000 )
uiDelta = 600 * 1000;
// Add delta to accumulator
llCurrent += uiDelta;
// Add debug value
llCurrent += ms_llTickCountAdd;
ms_llTickCountAdd = 0;
long long llResult = llCurrent;
ms_criticalSection.Unlock ();
return llResult;
}
示例9: SMT_InsertOneTaskResult
//插入1条任务结果
bool CSmartCommunicationDlg::SMT_InsertOneTaskResult(SMARTTASKRESULT mTaskResult)
{
g_CriticalSectionLock.Lock();
g_LSaveTaskResult.push_back(mTaskResult);
g_CriticalSectionLock.Unlock();
return true;
}
示例10: ProcessMessageServer
void CDummyWnd::ProcessMessageServer(CMessage *pMsg)
{
COMMON_PACKET cmnpck;
pMsg->GetData(&cmnpck, 0, sizeof(cmnpck));
switch(cmnpck.header) // ÆÐŶ Çì´õ °Ë»ö
{
case GSM_SERVERINFO : // °ÔÀÓ ¼¹ö Á¤º¸ÀÏ °æ¿ì
{
//AfxMessageBox("°ÔÀÓ ¼¹ö Á¤º¸ ÀúÀå.");
SERVERINFO si;
CHANNELINFO ci;
int nLen = pMsg->GetData(&si, 0, sizeof(si)); // ¿ì¼± °ÔÀÓ ¼¹ö ÀÚüÀÇ Á¤º¸¸¦ ¾òÀ½
LPSERVER server = m_ServerManager.GetServer((SOCKET)pMsg->GetSocket()); // ÆÐŶÀ» º¸³½ ¼¹ö¸¦ ãÀ½
if(server != NULL) // Á¤»óÀûÀÎ ¼¹ö Æ÷ÀÎÅ͸¦ °¡Á®¿ÔÀ» °æ¿ì
{
server->id = si.id; // ¼¹öÀÇ ¾ÆÀ̵ð ÀúÀå
server->ip = (char *)si.ip; // ¾ÆÀÌÇÇ ÀúÀå
server->portno = si.port; // Æ÷Æ®¹øÈ£ ÀúÀå
server->maxchannel = si.channels;
server->rooms = si.rooms;
if(!server->channel.size()) // ÃÖÃÊ¿¡ Á¢¼ÓÇÑ ¼¹öÀÏ °æ¿ì ä³ÎÁ¤º¸°¡ ¾øÀ½
{
CHANNEL channel;
for(int i = 0 ; i < si.channels ; i++) // Àüü ä³Î°¹¼ö¸¸Å
{
nLen += pMsg->GetData(&ci, nLen, sizeof(ci)); // ä³Î Á¤º¸¸¦ Çϳª¾¿ Àоî¿È
channel = ci; // ä³ÎÁ¤º¸¸¦ Çϳª¾¿ ÀúÀå
server->channel.push_back(channel); // ä³ÎÀ» ¸®½ºÆ®¿¡ Ãß°¡
}
}
else // ÀÌ¹Ì Ã¤³Î Á¤º¸°¡ Á¸ÀçÇÒ °æ¿ì // ÁÖ±âÀûÀÎ ¼¹ö Á¤º¸ÀÇ ¿äûÀÏ °æ¿ì
{
g_Critical.Lock();
list<CHANNEL>::iterator i = server->channel.begin();
for(; i != server->channel.end() ; i++)
{
LPCHANNEL lpchannel = &(*i);
nLen += pMsg->GetData(&ci, nLen, sizeof(ci));
*lpchannel = ci;
}
g_Critical.Unlock();
}
}
}
break;
}
}
示例11: StatsNumResponsesInc
void StatsNumResponsesInc( void )
{
ms_StatsCS.Lock();
ms_AllocationStats.uiTotalNumResponses++;
ms_AllocationStats.uiActiveNumResponses++;
ms_StatsCS.Unlock();
}
示例12: 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;
}
示例13: StatsBytesAllocated
void StatsBytesAllocated( int nBodyLength )
{
ms_StatsCS.Lock();
ms_AllocationStats.uiTotalKBAllocated += nBodyLength / 1024;
ms_AllocationStats.uiActiveKBAllocated += nBodyLength / 1024;
ms_StatsCS.Unlock();
}
示例14: UpdateLoadLog
//Thread safe way to update the load log
void CLoadLTADlg::UpdateLoadLog()
{
CString sTextToAdd;
g_LoadLogPipeCS.Lock(INFINITE);
sTextToAdd = sm_sLoadLogPipe;
sm_sLoadLogPipe = "";
g_LoadLogPipeCS.Unlock();
if(!sTextToAdd.IsEmpty())
{
CString sLogText;
CEdit* pEdit = ((CEdit*)GetDlgItem(IDC_LOADLOG));
pEdit->GetWindowText(sLogText);
sLogText += sTextToAdd;
pEdit->SetWindowText(sLogText);
pEdit->LineScroll(pEdit->GetLineCount());
}
}
示例15: ClearLoadLog
//Thread safe way to clear the load log
void CLoadLTADlg::ClearLoadLog()
{
g_LoadLogPipeCS.Lock(INFINITE);
sm_sLoadLogPipe = "";
g_LoadLogPipeCS.Unlock();
}