本文整理汇总了C++中CMutex类的典型用法代码示例。如果您正苦于以下问题:C++ CMutex类的具体用法?C++ CMutex怎么用?C++ CMutex使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CMutex类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: close
/**
* Close device.
*
* Removes all sessions to a connection. Though, clientLib rejects the closeDevice()
* command if still sessions connected to the device, this is needed to clean up all
* sessions if client dies.
*/
void MobiCoreDevice::close(Connection *connection)
{
trustletSessionList_t::reverse_iterator interator;
static CMutex mutex;
// 1. Iterate through device session to find connection
// 2. Decide what to do with open Trustlet sessions
// 3. Remove & delete deviceSession from vector
// Enter critical section
mutex.lock();
for (interator = trustletSessions.rbegin();
interator != trustletSessions.rend();
interator++) {
TrustletSession *ts = *interator;
if (ts->deviceConnection == connection) {
closeSession(connection, ts->sessionId);
}
}
// Leave critical section
mutex.unlock();
// After the trustlet is done make sure to tell the driver to cleanup
// all the orphaned drivers
cleanupWsmL2();
connection->connectionData = NULL;
}
开发者ID:IllusionRom-deprecated,项目名称:android_platform_hardware_samsung_slsi_exynos5,代码行数:35,代码来源:MobiCoreDevice.cpp
示例2: lock
String CHttpServer::directRequest( const String& method, const String& uri, const String& query, const HeaderList& headers ,const String& body )
{
common::CMutexLock lock(m_mxSyncRequest);
String ret;
if ( m_pQueue != 0 )
{
CDirectHttpRequestQueue::CDirectHttpRequest req;
pthread_cond_t signal;
pthread_cond_init(&signal,0);
CMutex m;
req.signal = &signal;
req.mutex = m.getNativeMutex();
req.method = method;
req.uri = uri;
req.query = query;
req.headers = headers;
req.body = body;
pthread_mutex_lock(m.getNativeMutex());
m_pQueue->doRequest( req );
pthread_cond_wait(&signal, m.getNativeMutex());
pthread_mutex_unlock(m.getNativeMutex());
ret = m_pQueue->getResponse();
}
return ret;
}
示例3: setPreparedCallback
//设置一个回调函数,当数据准备好后,将数据回馈过去
void ZTDataBase::setPreparedCallback(DataProparedFunc *callbackFunc){
CMutex mutex;
mutex.Lock();
m_callbackfunc = callbackFunc;
mutex.Unlock();
}
示例4: dyn_lock_callback
static void dyn_lock_callback(int mode, CRYPTO_dynlock_value *dlock, const char *file, int line) {
CMutex *mtx = (CMutex*)dlock;
if(mode & CRYPTO_LOCK) {
mtx->lock();
} else {
mtx->unlock();
}
}
示例5: DuplicateBootCheck
void DuplicateBootCheck(LPCTSTR mutexName)
{
CMutex mutex;
try{
mutex.createMutex(mutexName);
}catch(std::exception e){
::ErrorMessageBox(L"多重起動です");
exit(0);
}
}
示例6:
CNetRange *GetNetRange(list<CNetRange> &plNetRanges)
{ g_mScanner.Lock();
int iHighestScore=0; CNetRange *pNetRange=NULL;
for(list<CNetRange>::iterator in=plNetRanges.begin(); in!=plNetRanges.end(); in++)
{ int iScore=brandom(0, (*in).iPriority);
if(iScore > iHighestScore) { iHighestScore=iScore; pNetRange=&(*in); } }
g_mScanner.Unlock(); return pNetRange; }
示例7: SendHeartbeat
bool SendHeartbeat (bool bWithStash) {
LOGDEBUG (TEXT ("Sending heartbeat message"));
FudgeStatus status;
FudgeMsg msg;
if ((status = FudgeMsg_create (&msg)) != FUDGE_OK) {
LOGFATAL (TEXT ("Couldn't create message, status ") << status);
assert (0);
return false;
}
if ((status = ConnectorMessage_setOperation (msg, HEARTBEAT)) != FUDGE_OK) {
FudgeMsg_release (msg);
LOGFATAL (TEXT ("Couldn't create message, status ") << status);
assert (0);
return false;
}
if (bWithStash) {
m_oStashMutex.Enter ();
if (m_msgStash) {
if ((status = ConnectorMessage_setStash (msg, m_msgStash)) != FUDGE_OK) {
LOGFATAL (TEXT ("Couldn't create message, status ") << status);
assert (0);
status = FUDGE_OK;
// Not good, but can carry on
}
}
m_oStashMutex.Leave ();
}
bool bResult = m_poService->Send (MESSAGE_DIRECTIVES_CLIENT, msg);
FudgeMsg_release (msg);
return bResult;
}
示例8: sizeof
//////////////////////////////////////////////////////////////////////////
//
// Function Name: ViewFinderCallBackFun
// Description: The function which receives the picture from a camera
// Parameters: cdVoid *pBuf
// cdUInt32 Size
// cdUInt32 Format
// cdContext Context
// Returns: cdError code
// Summary:
// Author: CannonSDK
///////////////////////////////////////////////////////////////////////////
cdUInt32 cdSTDCALL CCameraConnect::ViewFinderCallBackFun( cdVoid *pBuf,
cdUInt32 Size,
cdUInt32 Format,
cdContext Context )
{
cdError err=cdOK;
LPBYTE bpPixel;
PBITMAPFILEHEADER pBmpFileheader;
PBITMAPINFOHEADER pBmpInfoheader;
CCameraConnect *CpThis;
CpThis = (CCameraConnect*)Context;
if( Format == FILEFORMAT_BMP )
{
pBmpFileheader = (PBITMAPFILEHEADER)pBuf;
pBmpInfoheader = (PBITMAPINFOHEADER)((LPBYTE)pBuf + sizeof(BITMAPFILEHEADER));
bpPixel = (LPBYTE)pBuf + pBmpFileheader->bfOffBits;
// A picture is saved at a buffer.
g_CVFMutex.Lock();
memcpy(CpThis->m_BackSurface.vpBits, bpPixel, pBmpInfoheader->biSizeImage );
g_CVFMutex.Unlock();
// A picture is displayed.
g_CpVFThread->ResumeThread();
}
return err;
}
示例9: CheckClock
void CTxWndDrawClockMgr::CheckClock( UINT nClockIn )
{
g_mutexDrawClock.Lock(1000);
MAPCLOCLKDATA::iterator itb = m_mapClockData.begin();
MAPCLOCLKDATA::iterator ite = m_mapClockData.end();
HWND hInvalidWnd = FALSE;
for (; itb != ite; itb++)
{
if (itb->second.nCurrentTick < nClockIn)
{
//send draw msg
if (::IsWindow(itb->first))
{
::PostMessage(itb->first, MSG_TXDRAWCLOCK, itb->second.wparam, itb->second.lparam);
itb->second.nCurrentTick = nClockIn + itb->second.nTickInternal;
}
else
{
//error;
hInvalidWnd = itb->first;
}
}
}
g_mutexDrawClock.Unlock();
if (hInvalidWnd != NULL)
{
ST_DRAWCLOCKDATA data;
data.hwnd = hInvalidWnd;
UnRegisterDrawClock(data);
}
}
示例10: deleteInstance
void CAppManConnectController::deleteInstance()
{
gInstanceMutex.lock();
delete mspInstance;
mspInstance = 0;
gInstanceMutex.unlock();
}
示例11: getStopFlag
bool CThread::getStopFlag() const
{
mStopFlagMutex.lock();
bool stop = mStopFlag;
mStopFlagMutex.unlock();
return stop;
}
示例12: SetHeaderControlText
void LListCtrl::SetHeaderControlText( DWORD dwPos, const CUString& strValue )
{
myLockListCtrl.Lock();
if ( m_hWnd )
{
CHeaderCtrl* pHeaderCtrl = GetHeaderCtrl();
ASSERT( (int)dwPos < pHeaderCtrl->GetItemCount() );
HDITEM hdi;
memset( &hdi, 0, sizeof( HDITEM ) );
// Get header item data
pHeaderCtrl->GetItem( dwPos, &hdi );
// modify item data
CUStringConvert strCnv;
hdi.pszText = strCnv.ToT( strValue );
hdi.mask = HDI_TEXT;
// Set item data
pHeaderCtrl->SetItem( dwPos, &hdi );
}
myLockListCtrl.Unlock();
}
示例13: PrintErrorV
AFS_API int32 PrintErrorV(const char* sFormat, CVaList& pArgList)
{
g_oStdOutMutex.Enter();
int32 nRet = CSingleInstance<CStdErrFormatter>::GetInstance()->oFormatter.PrintV(sFormat, pArgList);
g_oStdOutMutex.Leave();
return nRet;
}
示例14: ScanV
AFS_API int32 ScanV(const char* sFormat, CVaList& pArgList)
{
g_oStdInMutex.Enter();
int32 nRet = CSingleInstance<CStdInFormatter>::GetInstance()->oFormatter.ScanV(sFormat, pArgList);
g_oStdInMutex.Leave();
return nRet;
}
示例15:
CAcmUdp::~CAcmUdp()
{
if(m_bRegistered)
{
g_oMutex.Enter();
g_oUdpTable.Remove(m_nDomain);
g_oMutex.Leave();
}
}