本文整理汇总了C++中GetLock函数的典型用法代码示例。如果您正苦于以下问题:C++ GetLock函数的具体用法?C++ GetLock怎么用?C++ GetLock使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GetLock函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PrintAllocations
void PrintAllocations( )
{
GetLock( ).lock( );
#ifdef DEBUG_MEMORY
Header* header = GetBottom( )->Next;
std::string str = "\n";
while ( header )
{
if ( !header->Free )
str += "\tMEMORY LEAK\t\t" + std::string( header->File ) + ":" + std::to_string( header->Line ) + "\t\t" + std::to_string( header->Size ) + "\n";
header = header->Next;
}
header = GetTop( )->Next;
while ( header )
{
if ( !header->Free )
str += "\tMEMORY LEAK\t\t" + std::string( header->File ) + ":" + std::to_string( header->Line ) + "\t\t" + std::to_string( header->Size ) + "\n";
header = header->Next;
}
str += "\n";
#if PLATFORM == PLATFORM_WINDOWS
OutputDebugStringA( str.c_str( ) );
#else
printf( "%s", str.c_str( ) );
#endif
#endif
GetLock( ).unlock( );
}
示例2: xnOSEnterCriticalSection
XnStatus XnSensorDepthStream::SetMirror(XnBool bIsMirrored)
{
XnStatus nRetVal = XN_STATUS_OK;
xnOSEnterCriticalSection(GetLock());
// set firmware mirror
XnBool bFirmwareMirror = (bIsMirrored == TRUE && m_Helper.GetFirmwareVersion() >= XN_SENSOR_FW_VER_5_0);
nRetVal = m_Helper.SimpleSetFirmwareParam(m_FirmwareMirror, (XnUInt16)bFirmwareMirror);
if (nRetVal != XN_STATUS_OK)
{
xnOSLeaveCriticalSection(GetLock());
return (nRetVal);
}
// update prop
nRetVal = XnDepthStream::SetMirror(bIsMirrored);
xnOSLeaveCriticalSection(GetLock());
XN_IS_STATUS_OK(nRetVal);
if (m_depthUtilsHandle != NULL)
{
nRetVal = DepthUtilsSetDepthConfiguration(m_depthUtilsHandle, GetXRes(), GetYRes(), GetOutputFormat(), IsMirrored());
XN_IS_STATUS_OK(nRetVal);
}
return (XN_STATUS_OK);
}
示例3: Intercept
static BOOL Intercept(THREADID tid, DEBUGGING_EVENT eventType, CONTEXT *ctxt, VOID *)
{
if (eventType == DEBUGGING_EVENT_BREAKPOINT)
{
// When the child thread reaches the breakpoint in Breakpoint(), wait for the main
// thread to reach the One() function. If the main thread is not there yet, squash the
// breakpoint and move the PC back to the start of the Breakpoint() function. This will
// delay a while and then re-trigger the breakpoint.
//
ADDRINT pc = PIN_GetContextReg(ctxt, REG_INST_PTR);
if (pc == BreakpointLocation && !AllowBreakpoint)
{
PIN_SetContextReg(ctxt, REG_INST_PTR, BreakpointFunction);
GetLock(&Lock, 1);
std::cout << "Squashing breakpoint at 0x" << std::hex << pc << " on thread " << std::dec << tid << std::endl;
ReleaseLock(&Lock);
return FALSE;
}
GetLock(&Lock, 1);
std::cout << "Stopping at breakpoint at 0x" << std::hex << pc << " on thread " << std::dec << tid << std::endl;
ReleaseLock(&Lock);
return TRUE;
}
if (eventType == DEBUGGING_EVENT_ASYNC_BREAK)
{
// When the child thread triggers the breakpoint, we should be at the One() function.
// Change the PC to the Two() function, which is the point of this test. We want to
// make sure Pin properly handles the change of PC in this case.
//
ADDRINT pc = PIN_GetContextReg(ctxt, REG_INST_PTR);
if (pc == OneFunction)
{
PIN_SetContextReg(ctxt, REG_INST_PTR, TwoFunction);
GetLock(&Lock, 1);
std::cout << "Changing ASYNC BREAK PC to Two() on thread " << std::dec << tid << std::endl;
ReleaseLock(&Lock);
return TRUE;
}
// If the PC is not at the One() function, the child thread has probably hit some breakpoint
// other than the one at Breakpoint(). (E.g. an internal breakpoint set by GDB.) Don't
// change the PC in such a case.
//
GetLock(&Lock, 1);
std::cout << "ASYNC_BREAK at 0x" << std::hex << pc << " on thread " << std::dec << tid << std::endl;
ReleaseLock(&Lock);
return TRUE;
}
GetLock(&Lock, 1);
std::cout << "FAILURE: Unexpected debugging event type" << std::endl;
ReleaseLock(&Lock);
std::exit(1);
}
示例4: add_or_update_alarm
int add_or_update_alarm(uint8_t hour, uint8_t min, uint8_t mode,
uint8_t repeat_factor, char *name)
{
pthread_mutex_t *bucket_mtx = GetLock(hour, min);
pthread_mutex_lock(bucket_mtx);
AlarmClockInfo *header = GetHeader(hour, min);
AlarmClockInfo *temp = header;
// Check whether an existing entry should be updated
while (temp)
{
if (temp->hour == hour && temp->min == min)
{
temp->mode = mode;
temp->repeat_factor = repeat_factor;
strcpy(temp->name, name);
pthread_mutex_unlock(bucket_mtx);
return 0;
}
temp = temp->next;
}
// A new entry is inserted
AlarmClockInfo *naci = CreateNewInfo(hour,min,mode,repeat_factor,name);
naci->next = header;
*AC_TABLE_ENTRY(hour,min) = naci;
pthread_mutex_unlock(bucket_mtx);
return 1;
}
示例5: cancel_alarm
// Return 1 if found and removed, otherwise return 0
int cancel_alarm(uint8_t hour, uint8_t min, int play)
{
pthread_mutex_t *bucket_mtx = GetLock(hour, min);
pthread_mutex_lock(bucket_mtx);
AlarmClockInfo *cand = GetHeader(hour, min);
AlarmClockInfo *prev = NULL;
while (cand)
{
if (cand->hour == hour && cand->min == min)
{
// Optionally, play the alarm here before essentially removing it
// ...
if (play)
; // sound an alarm
if (!prev) *AC_TABLE_ENTRY(hour, min) = cand->next;
else prev->next = cand->next;
free(cand);
pthread_mutex_unlock(bucket_mtx);
return 1;
}
prev = cand;
cand = cand->next;
}
pthread_mutex_unlock(bucket_mtx);
return 0;
}
示例6: GetLock
//-----------------------------------------
// функция логирует события мыши
//-----------------------------------------
bool TKeyLogger::LogMouse(HWND Wnd, int X, int Y, int Button)
{
//------ блокируем код --------
TLock L = GetLock();
//------------------------------
return true;
}
示例7: GetPlayerDataCache
void AccountMgr::ClearPlayerDataCache(ObjectGuid guid)
{
if (!guid || !guid.IsPlayer())
return;
PlayerDataCache const* cache = GetPlayerDataCache(guid, false);
if (cache)
{
uint32 accId = cache->account;
WriteGuard Guard(GetLock());
PlayerDataCacheMap::iterator itr = mPlayerDataCacheMap.find(guid);
if (itr != mPlayerDataCacheMap.end())
mPlayerDataCacheMap.erase(itr);
RafLinkedMap::iterator itr1 = mRAFLinkedMap.find(std::pair<uint32,bool>(accId, true));
if (itr1 != mRAFLinkedMap.end())
mRAFLinkedMap.erase(itr1);
itr1 = mRAFLinkedMap.find(std::pair<uint32,bool>(accId, false));
if (itr1 != mRAFLinkedMap.end())
mRAFLinkedMap.erase(itr1);
}
}
示例8: NOW
RafLinkedList* AccountMgr::GetRAFAccounts(uint32 accid, bool referred)
{
RafLinkedMap::iterator itr = mRAFLinkedMap.find(std::pair<uint32,bool>(accid, referred));
if (itr == mRAFLinkedMap.end())
{
QueryResult* result;
if (referred)
result = LoginDatabase.PQuery("SELECT `friend_id` FROM `account_friends` WHERE `id` = %u AND `expire_date` > NOW() LIMIT %u", accid, sWorld.getConfig(CONFIG_UINT32_RAF_MAXREFERERS));
else
result = LoginDatabase.PQuery("SELECT `id` FROM `account_friends` WHERE `friend_id` = %u AND `expire_date` > NOW() LIMIT %u", accid, sWorld.getConfig(CONFIG_UINT32_RAF_MAXREFERALS));
RafLinkedList acclist;
if (result)
{
do
{
Field* fields = result->Fetch();
uint32 refaccid = fields[0].GetUInt32();
acclist.push_back(refaccid);
}
while (result->NextRow());
delete result;
}
ReadGuard Guard(GetLock());
mRAFLinkedMap.insert(RafLinkedMap::value_type(std::pair<uint32,bool>(accid, referred), acclist));
itr = mRAFLinkedMap.find(std::pair<uint32,bool>(accid, referred));
}
return &itr->second;
}
示例9: BeforeMalloc
// This routine is executed each time malloc is called.
VOID BeforeMalloc( int size, THREADID threadid )
{
GetLock(&lock, threadid+1);
fprintf(out, "thread %d entered malloc(%d)\n", threadid, size);
fflush(out);
ReleaseLock(&lock);
}
示例10: main
int main(int argc, char **argv)
{
if(InitLocks("qlite", "sapc13", 5468))
{
if(GetLock(1, 5)==0)
printf("Got lock!\n");
else
printf("Lock denied!\n");
/*
if(GetLock(1, 5)==0)
printf("Got lock!\n");
else
printf("Lock denied!\n");
if(ReleaseLock(1))
printf("Lock released!\n");
else
printf("Couldn't release lock!\n");
if(GetLock(1, 5)==0)
printf("Got lock!\n");
else
printf("Lock denied!\n");
if(ReleaseLock(2))
printf("Lock released!\n");
else
printf("Couldn't release lock!\n");
*/
}
return(0);
}
示例11: ThreadStart
// Note that opening a file in a callback is only supported on Linux systems.
// See buffer-win.cpp for how to work around this issue on Windows.
//
// This routine is executed every time a thread is created.
VOID ThreadStart(THREADID threadid, CONTEXT *ctxt, INT32 flags, VOID *v)
{
GetLock(&lock, threadid+1);
fprintf(out, "thread begin %d\n",threadid);
fflush(out);
ReleaseLock(&lock);
}
示例12: lock
T* HashMapHolder<T>::Find(ObjectGuid guid)
{
boost::shared_lock<boost::shared_mutex> lock(*GetLock());
typename MapType::iterator itr = GetContainer().find(guid);
return (itr != GetContainer().end()) ? itr->second : NULL;
}
示例13: cCS0
int
C_File::AddLock( LockStruct *ls, BOOL bWait )
{
C_FileCritSect cCS0( this, CRITSECT0 );
LockStruct *lsAux = GetLock( ls );
if( lsAux ){
lsAux->iCount++;
if( ls ){
delete ls;
}
return( OK );
} else {
if( !IsLocked( ls, TRUE ) ){
ls->iCount++;
if( _LockTable [ iLine ]->Add( ls, TAIL ) == OK ){
if( RealLock( ls, bWait ) == OK ){
return( OK );
} else {
_LockTable [ iLine ]->Refresh( NULL );
_LockTable [ iLine ]->Del();
}
}
}
}
return( !OK );
}
示例14: locker
void OPFResource::AddSigilVersionMeta()
{
QWriteLocker locker(&GetLock());
QString source = CleanSource::ProcessXML(GetText(),"application/oebps-package+xml");
OPFParser p;
p.parse(source);
for (int i=0; i < p.m_metadata.count(); ++i) {
MetaEntry me = p.m_metadata.at(i);
if ((me.m_name == "meta") && (me.m_atts.contains("name"))) {
QString name = me.m_atts[QString("name")];
if (name == SIGIL_VERSION_META_NAME) {
me.m_atts["content"] = QString(SIGIL_VERSION);
p.m_metadata.replace(i, me);
UpdateText(p);
return;
}
}
}
MetaEntry me;
me.m_name = "meta";
me.m_atts[QString("name")] = QString("Sigil version");
me.m_atts[QString("content")] = QString(SIGIL_VERSION);
p.m_metadata.append(me);
UpdateText(p);
}
示例15: Image
VOID Image(IMG img, VOID *v){
char szFilePath[260];
unsigned long index;
GetLock(&lock, 1);
if (process_start != 0){
ReleaseLock(&lock);
return;
}
if (IMG_Valid(img)){
memset(szFilePath, 0, sizeof(szFilePath));
strncpy(szFilePath, IMG_Name(img).c_str(), sizeof(szFilePath)-1);
index = 0;
while (szFilePath[index] != 0){
szFilePath[index] = tolower(szFilePath[index]);
index++;
}
if (strstr(szFilePath, KnobProcessToTrace.Value().c_str())){
process_start = IMG_LowAddress(img);
process_end = IMG_HighAddress(img);
}
}
ReleaseLock(&lock);
}