• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ GetLock函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中GetLock函数的典型用法代码示例。如果您正苦于以下问题:C++ GetLock函数的具体用法?C++ GetLock怎么用?C++ GetLock使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了GetLock函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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( );
	}
开发者ID:Robograde,项目名称:Robograde,代码行数:31,代码来源:Allocator.cpp


示例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);
}
开发者ID:jan-vitek,项目名称:OpenNI2,代码行数:30,代码来源:XnSensorDepthStream.cpp


示例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);
}
开发者ID:alagenchev,项目名称:school_code,代码行数:56,代码来源:pc-change-async-tool.cpp


示例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;
}
开发者ID:Milchdealer,项目名称:Atlas,代码行数:27,代码来源:alarm_clock.c


示例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;
}
开发者ID:Milchdealer,项目名称:Atlas,代码行数:28,代码来源:alarm_clock.c


示例6: GetLock

//-----------------------------------------
// функция логирует события мыши
//-----------------------------------------
bool TKeyLogger::LogMouse(HWND Wnd, int X, int Y, int Button)
{
	//------  блокируем код --------
	TLock L = GetLock();
	//------------------------------
	return true;
}
开发者ID:0x00dec0de,项目名称:Carberp,代码行数:10,代码来源:KeyLogger.cpp


示例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);
    }

}
开发者ID:AnthoDevMoP,项目名称:mangos4,代码行数:25,代码来源:AccountMgr.cpp


示例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;
}
开发者ID:AnthoDevMoP,项目名称:mangos4,代码行数:33,代码来源:AccountMgr.cpp


示例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);
}
开发者ID:gungun1010,项目名称:hidden,代码行数:8,代码来源:malloc_mt.cpp


示例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);
}
开发者ID:AndrewCRMartin,项目名称:qlite,代码行数:34,代码来源:qlclient.c


示例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);
}
开发者ID:gungun1010,项目名称:hidden,代码行数:11,代码来源:malloc_mt.cpp


示例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;
}
开发者ID:Diyvol,项目名称:TrinityCore,代码行数:7,代码来源:ObjectAccessor.cpp


示例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 );
}
开发者ID:softwarepublico,项目名称:lightbase,代码行数:26,代码来源:WDFILECL.CPP


示例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);
}
开发者ID:wrCisco,项目名称:Sigil,代码行数:25,代码来源:OPFResource.cpp


示例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);
        
}
开发者ID:IDA-RE-things,项目名称:IDA-pinlog,代码行数:26,代码来源:main.cpp


示例16: Fini

/*!
 * Print out analysis results.
 * This function is called when the application exits.
 * @param[in]   code            exit code of the application
 * @param[in]   v               value specified by the tool in the 
 *                              PIN_AddFiniFunction function call
 */
VOID Fini(INT32 code, VOID *v)
{
    GetLock(&fileLock, 1);
    fclose(outfile);
    printf("outfile closed\n");
    ReleaseLock(&fileLock);
}
开发者ID:gungun1010,项目名称:hidden,代码行数:14,代码来源:two_buffers.cpp


示例17: ThreadFini

// This routine is executed every time a thread is destroyed.
VOID ThreadFini(THREADID threadid, const CONTEXT *ctxt, INT32 code, VOID *v)
{
    GetLock(&lock, threadid+1);
    fprintf(out, "thread end %d code %d\n",threadid, code);
    fflush(out);
    ReleaseLock(&lock);
}
开发者ID:gungun1010,项目名称:hidden,代码行数:8,代码来源:malloc_mt.cpp


示例18: DEBUG_FILTER_LOG

// call this method only
void TerrainInfo::CleanUpGrids(uint32 const diff)
{
    for (int y = 0; y < MAX_NUMBER_OF_GRIDS; ++y)
    {
        for (int x = 0; x < MAX_NUMBER_OF_GRIDS; ++x)
        {
            // delete those GridMap objects which have refcount == 0
            if (m_GridMaps[x][y] && m_GridMaps[x][y].count() == 0)
            {
                DEBUG_FILTER_LOG(LOG_FILTER_MAP_LOADING,"TerrainInfo::CleanUpGrids unload grid map:%u x:%d y:%d", GetMapId(), x, y);
                WriteGuard Guard(GetLock(), true);

                GridMapPtr tmpPtr = m_GridMaps[x][y];
                m_GridMaps[x][y] = GridMapPtr();

                // unload VMAPS...
                VMAP::VMapFactory::createOrGetVMapManager()->unloadMap(m_mapId, x, y);

                // unload mmap...
                MMAP::MMapFactory::createOrGetMMapManager()->unloadMap(m_mapId, x, y);

                // tmpPtr be auto-erased after cycle end
            }
        }
    }
}
开发者ID:Jojo2323,项目名称:mangos3,代码行数:27,代码来源:GridMap.cpp


示例19: locker

void TextResource::InitialLoad()
{
    /**
      * Stuff to know about resource loading...
      *
      * Currently Sigil when opening an ePub creates Resource objects *prior*
      * to actually copying the resources from the zip into the Sigil folders.
      * So in 99% of cases the resource will not exist, so a call to InitialLoad()
      * from the constructor would fail (which it used to do).
      *
      * For some resource types there is a call made afterwards which will result
      * in the resource being loaded such as for HTML files, CSS, NCX and OPF
      * (see UniversalUpdates.cpp and code setting default text for new html pages etc).
      *
      * For other text resource types, they will only get loaded on demand, when
      * the tab is actually opened, TextTab.cpp will call this InitialLoad() function.
      *
      * If you were to write some code to iterate over resources that do not fall
      * into the special cases above, you *must* call InitialLoad() first to ensure
      * the data is loaded, or else it will be blank or have data depending on whether
      * it had been opened in a tab first.
      */
    QWriteLocker locker(&GetLock());
    Q_ASSERT(m_TextDocument);

    if (m_TextDocument->toPlainText().isEmpty() && QFile::exists(GetFullPath())) {
        SetText(Utility::ReadUnicodeTextFile(GetFullPath()));
    }
}
开发者ID:AmesianX,项目名称:Sigil,代码行数:29,代码来源:TextResource.cpp


示例20: Error

VOID Error(std::string where, THREADID tid, UINT32 r, ADDRINT expect, ADDRINT val)
{
    GetLock(&Lock, 1);
    Out << "Mismatch " << where << ": tid=" << std::dec << tid << " (G" << r << ")" <<
        ", Expect " << std::hex << expect << ", Got " << std::hex << val << std::endl;
    ReleaseLock(&Lock);
}
开发者ID:dcashman,项目名称:Coursework,代码行数:7,代码来源:reg_inst_gx.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ GetLogicDate函数代码示例发布时间:2022-05-30
下一篇:
C++ GetLocation函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap