本文整理汇总了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 );
}
}
示例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);
}
}
示例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 );
}
}