当前位置: 首页>>代码示例>>C++>>正文


C++ Mutex::AttemptAcquire方法代码示例

本文整理汇总了C++中Mutex::AttemptAcquire方法的典型用法代码示例。如果您正苦于以下问题:C++ Mutex::AttemptAcquire方法的具体用法?C++ Mutex::AttemptAcquire怎么用?C++ Mutex::AttemptAcquire使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Mutex的用法示例。


在下文中一共展示了Mutex::AttemptAcquire方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: OnCrash

// Crash Handler
void OnCrash( bool Terminate )
{
	sLog.outString( "Advanced crash handler initialized." );

	if( !m_crashedMutex.AttemptAcquire() )
		TerminateThread( GetCurrentThread(), 0 );

	try
	{
		if( ClusterMgr::getSingletonPtr() != 0 )
		{
			sLog.outString( "Waiting for all database queries to finish..." );
			WorldDatabase.EndThreads();
			CharacterDatabase.EndThreads();
			sLog.outString( "All pending database operations cleared.\n" );
			//sClusterMgr.SaveAllPlayers();
			//sLog.outString( "Data saved." );
		}
	}
	catch(...)
	{
		sLog.outString( "Threw an exception while attempting to save all data." );
	}

	sLog.outString( "Closing." );

	// Terminate Entire Application
	if( Terminate )
	{
		HANDLE pH = OpenProcess( PROCESS_TERMINATE, TRUE, GetCurrentProcessId() );
		TerminateProcess( pH, 1 );
		CloseHandle( pH );
	}
}
开发者ID:Bootz,项目名称:Ascent_NG,代码行数:35,代码来源:Master.cpp

示例2: OnCrash

// Crash Handler
void OnCrash(bool Terminate)
{
	sLog.outString("Advanced crash handler initialized.");
	if(!m_crashedMutex.AttemptAcquire())
		TerminateThread(GetCurrentThread(), 0);

	try
	{
		if(World::getSingletonPtr() != 0 && ThreadMgr::getSingletonPtr() != 0)
		{
			sLog.outString("Waiting for all database queries to finish...");
			MySQLDatabase* dbThread = (MySQLDatabase*)sThreadMgr.GetThreadByType(THREADTYPE_DATABASE);
			if(dbThread != 0)
			{
				// end it
				MySQLDatabase * dbThread2 = (MySQLDatabase*)Database_World;
				dbThread = (MySQLDatabase*)Database_Character;
				dbThread->SetThreadState(THREADSTATE_TERMINATE);
				dbThread2->SetThreadState(THREADSTATE_TERMINATE);
				CharacterDatabase.Execute("UPDATE characters SET online = 0");
				WorldDatabase.Execute("UPDATE characters SET online = 0");
				// wait for it to finish its work
				while(dbThread->ThreadRunning || dbThread2->ThreadRunning)
				{
					Sleep(100);
				}
			}
			sLog.outString("All pending database operations cleared.\n");
			sWorld.SaveAllPlayers();
			sLog.outString("Data saved.");
		}
	}
	catch(...)
	{
		sLog.outString("Threw an exception while attempting to save all data.");
	}

	sLog.outString("Closing.");
	
	// beep
	//printf("\x7");
	
	// Terminate Entire Application
	if(Terminate)
	{
		HANDLE pH = OpenProcess(PROCESS_TERMINATE, TRUE, GetCurrentProcessId());
		TerminateProcess(pH, 1);
		CloseHandle(pH);
	}
}
开发者ID:Sylica2013,项目名称:Antrix,代码行数:51,代码来源:Master.cpp

示例3: OnCrash

// Crash Handler
void OnCrash( bool Terminate )
{
		Log.Error( "Crash Handler","Advanced crash handler initialized." );

	if( !m_crashedMutex.AttemptAcquire() )
		TerminateThread( GetCurrentThread(), 0 );

	try
	{
		if( World::getSingletonPtr() != 0 )
		{
			Log.Notice( "sql","All pending database operations cleared.\n" );
			sWorld.SaveAllPlayers();
			Log.Notice( "sql","Data saved." );
			Log.Notice( "sql","Waiting for all database queries to finish..." );
			WorldDatabase.EndThreads();
			CharacterDatabase.EndThreads();
			LogonDatabase.EndThreads();
		}
	}
	catch(...)
	{
		Log.Error( "sql","Threw an exception while attempting to save all data." );
	}

	Log.Notice( "Server","Closing." );
	
	// beep
	//printf("\x7");
	
	// Terminate Entire Application
	if( Terminate )
	{
		HANDLE pH = OpenProcess( PROCESS_TERMINATE, TRUE, GetCurrentProcessId() );
		TerminateProcess( pH, 1 );
		CloseHandle( pH );
	}
}
开发者ID:AtVirus,项目名称:Descent-core,代码行数:39,代码来源:Master.cpp


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