本文整理汇总了C++中CElapsedTime::Get方法的典型用法代码示例。如果您正苦于以下问题:C++ CElapsedTime::Get方法的具体用法?C++ CElapsedTime::Get怎么用?C++ CElapsedTime::Get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CElapsedTime
的用法示例。
在下文中一共展示了CElapsedTime::Get方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: HasData
///////////////////////////////////////////////////////////////
//
// CMasterServerManager::HasData
//
//
//
///////////////////////////////////////////////////////////////
bool CMasterServerManager::HasData ( void )
{
// Count how many server have responded
uint uiHasDataCount = 0;
for ( uint i = 0 ; i < m_MasterServerList.size () && i < m_iActiveAmount ; i++ )
if ( m_MasterServerList[i]->HasData () )
uiHasDataCount++;
// If two servers responded, then success
if ( uiHasDataCount >= 2 )
return true;
// If less than 2 servers responded, and it's been 2.5 seconds, try to add a new server
if ( uiHasDataCount < 2 && m_ElapsedTime.Get () > 2500 )
{
if ( m_iActiveAmount <= 2 && m_MasterServerList.size () > m_iActiveAmount )
{
m_MasterServerList[ m_iActiveAmount++ ]->Refresh ();
}
}
// If one server responded, and it's been 5 seconds, then success
if ( uiHasDataCount >= 1 && m_ElapsedTime.Get () > 5000 )
return true;
return false;
}
示例2: DoPulse
///////////////////////////////////////////////////////////////
//
// CPerfStatFunctionTimingImpl::DoPulse
//
//
//
///////////////////////////////////////////////////////////////
void CPerfStatFunctionTimingImpl::DoPulse ( void )
{
// Maybe turn off stats gathering if nobody is watching
if ( m_bIsActive && m_TimeSinceLastViewed.Get () > 15000 )
SetActive ( false );
// Do nothing if not active
if ( !m_bIsActive )
{
m_TimingMap.empty ();
return;
}
// Check if time to cycle the stats
if ( m_TimeSinceUpdate.Get () >= 5000 )
{
m_TimeSinceUpdate.Reset ();
// For each timed function
for ( std::map < SString, SFunctionTimingInfo >::iterator iter = m_TimingMap.begin () ; iter != m_TimingMap.end () ; )
{
SFunctionTimingInfo& item = iter->second;
// Update history
item.iPrevIndex = ( item.iPrevIndex + 1 ) % NUMELMS( item.history );
item.history[ item.iPrevIndex ] = item.now5s;
// Reset accumulator
item.now5s.uiNumCalls = 0;
item.now5s.fTotalMs = 0;
item.now5s.fPeakMs = 0;
// Recalculate last 60 second stats
item.prev60s.uiNumCalls = 0;
item.prev60s.fTotalMs = 0;
item.prev60s.fPeakMs = 0;
for ( uint i = 0 ; i < NUMELMS( item.history ) ; i++ )
{
const STiming& slot = item.history[i];
item.prev60s.uiNumCalls += slot.uiNumCalls;
item.prev60s.fTotalMs += slot.fTotalMs;
item.prev60s.fPeakMs = Max ( item.prev60s.fPeakMs, slot.fPeakMs );
}
// Remove from map if no calls in the last 60s
if ( item.prev60s.uiNumCalls == 0 )
m_TimingMap.erase ( iter++ );
else
++iter;
}
}
//
// Update PeakUs threshold
//
m_PeakUsRequiredHistory.RemoveOlderThan ( 10000 );
m_PeakUsThresh = m_PeakUsRequiredHistory.GetLowestValue ( DEFAULT_THRESH_MS * 1000 );
}
示例3: MaybeRecordStats
///////////////////////////////////////////////////////////////
//
// CPerfStatEventPacketUsageImpl::MaybeRecordStats
//
//
//
///////////////////////////////////////////////////////////////
void CPerfStatEventPacketUsageImpl::MaybeRecordStats ( void )
{
// Someone watching?
if ( m_TimeSinceGetStats.Get () < 10000 )
{
// Time for record update? // Copy and clear once every 5 seconds
long long llTime = GetTickCount64_ ();
if ( llTime >= m_llNextRecordTime )
{
m_llNextRecordTime = std::max ( m_llNextRecordTime + 5000, llTime + 5000 / 10 * 9 );
// Copy into a list and sort
m_EventUsageSortedList.clear();
for( std::map < SString, SEventUsage >::iterator iter = m_EventUsageLiveMap.begin() ; iter != m_EventUsageLiveMap.end() ; ++iter )
{
iter->second.strName = iter->first;
m_EventUsageSortedList.push_back( iter->second );
}
std::sort ( m_EventUsageSortedList.begin (), m_EventUsageSortedList.end (),
[](const SEventUsage& a, const SEventUsage& b)
{
return a.iTotal > b.iTotal;
});
m_EventUsageLiveMap.clear();
}
}
else
{
m_bEnabled = false;
}
}
示例4: Draw
///////////////////////////////////////////////////////////////
//
// CMemStats::Draw
//
//
//
///////////////////////////////////////////////////////////////
void CMemStats::Draw ( void )
{
if ( !m_bEnabled )
return;
UpdateFrameStats ();
// Time to update?
if ( m_UpdateTimer.Get () > 2000 )
{
m_UpdateTimer.Reset ();
UpdateIntervalStats ();
CreateTables ();
}
float fResWidth = static_cast < float > ( g_pGraphics->GetViewportWidth () );
float fResHeight = static_cast < float > ( g_pGraphics->GetViewportHeight () );
float fTotalHeight = 0;
// Draw tables
if ( !m_TableList.empty () )
{
float fX = fResWidth - m_TableList.front ().GetPixelWidth () - 15;
float fY = 200 - m_fPosY;
for ( std::list < CDxTable >::iterator iter = m_TableList.begin () ; iter != m_TableList.end () ; ++iter )
{
CDxTable& table = *iter;
table.Draw ( fX, fY, 0x78000000, 10, 10, 8, 8 );
float fHeight = table.GetPixelHeight () + 20;
fY += fHeight;
fTotalHeight += fHeight;
}
}
// Handle scrolling
bool bHoldingPageUp = ( GetAsyncKeyState ( VK_PRIOR ) & 0x8000 ) != 0;
bool bHoldingPageDown = ( GetAsyncKeyState ( VK_NEXT ) & 0x8000 ) != 0;
if ( bHoldingPageUp )
{
m_fPosY = std::max ( 0.f, m_fPosY - 10 );
}
if ( bHoldingPageDown )
{
float fScrollHeight = fTotalHeight - ( fResHeight - 200 );
if ( fScrollHeight > 0 )
m_fPosY = std::min ( fScrollHeight, m_fPosY + 10 );
}
}
示例5: RecordStats
///////////////////////////////////////////////////////////////
//
// CClientPerfStatPacketUsageImpl::RecordStats
//
//
//
///////////////////////////////////////////////////////////////
void CClientPerfStatPacketUsageImpl::RecordStats ( void )
{
if ( m_TimeSinceGetStats.Get () < 10000 )
{
// Save previous sample so we can calc the delta values
memcpy ( m_PrevPacketStats, m_PacketStats, sizeof ( m_PacketStats ) );
memcpy ( m_PacketStats, g_pNet->GetPacketStats (), sizeof ( m_PacketStats ) );
}
else
{
// No one watching
memset ( m_PrevPacketStats, 0, sizeof ( m_PacketStats ) );
memset ( m_PacketStats, 0, sizeof ( m_PacketStats ) );
}
}
示例6: UpdateDebugData
///////////////////////////////////////////////////////////////
//
// CDatabaseJobQueueImpl::UpdateDebugData
//
// Update info relevant to debugging database jobs
//
///////////////////////////////////////////////////////////////
void CDatabaseJobQueueImpl::UpdateDebugData ( void )
{
// Update once every 10 seconds
if ( m_JobCountElpasedTime.Get () < 10000 )
return;
shared.m_Mutex.Lock ();
// Log to console if connection count is creeping up
if ( shared.m_HandleConnectionMap.size() > m_uiConnectionCountWarnThresh )
{
m_uiConnectionCountWarnThresh = shared.m_HandleConnectionMap.size() * 2;
CLogger::LogPrintf( "Notice: There are now %d database connections\n", shared.m_HandleConnectionMap.size() );
}
// Log to console if job count is creeping up
m_uiJobCount10sMin = std::min < uint > ( m_uiJobCount10sMin, m_ActiveJobHandles.size () );
if ( m_uiJobCount10sMin > m_uiJobCountWarnThresh )
{
m_uiJobCountWarnThresh = m_uiJobCount10sMin * 2;
CLogger::LogPrintf ( "Notice: %d database query handles active in the last 10 seconds\n", m_uiJobCount10sMin );
}
m_JobCountElpasedTime.Reset ();
m_uiJobCount10sMin = m_ActiveJobHandles.size ();
CTickCount timeNow = CTickCount::Now ( true );
// Log old uncollected queries
for ( CJobQueueType::iterator iter = shared.m_ResultQueue.begin () ; iter != shared.m_ResultQueue.end () ; iter++ )
{
CDbJobData* pJobData = *iter;
if ( !pJobData->result.bLoggedWarning )
{
CTickCount age = timeNow - pJobData->result.timeReady;
if ( age.ToLongLong () > 1000 * 60 * 5 )
{
shared.m_Mutex.Unlock ();
g_pGame->GetScriptDebugging()->LogWarning( pJobData->m_LuaDebugInfo, "Database result uncollected after 5 minutes. [Query: %s]", *pJobData->GetCommandStringForLog() );
shared.m_Mutex.Lock ();
pJobData->result.bLoggedWarning = true;
break;
}
}
}
shared.m_Mutex.Unlock ();
}
示例7: MaybeTidyUp
////////////////////////////////////////////////////////////////
//
// CEffectClonerImpl::MaybeTidyUp
//
// Tidy up if been a little while since last time
//
////////////////////////////////////////////////////////////////
void CEffectClonerImpl::MaybeTidyUp ( bool bForceDrasticMeasures, CEffectTemplate* pKeepThis )
{
if ( !bForceDrasticMeasures && m_TidyupTimer.Get () < 1000 )
return;
m_TidyupTimer.Reset ();
// Everything in Old List can go if not being used
for ( uint i = 0 ; i < m_OldList.size () ; i++ )
{
CEffectTemplate* pEffectTemplate = m_OldList[i];
if ( pEffectTemplate != pKeepThis && pEffectTemplate->GetTicksSinceLastUsed () > ( bForceDrasticMeasures ? 0 : 1 ) )
{
OutputDebugLine ( "[Shader] CEffectClonerImpl::MaybeTidyUp: Releasing old EffectTemplate" );
SAFE_RELEASE( pEffectTemplate );
ListRemoveIndex ( m_OldList, i-- );
}
}
// Complex calculation to guess how long to leave an effect unused before deleting
// 0=30 mins 100=25 mins 200=16 mins 300=1 sec
float fTicksAlpha = UnlerpClamped ( 0, m_ValidMap.size (), 300 );
int iTicks = static_cast < int > ( ( 1 - fTicksAlpha * fTicksAlpha ) * 30 * 60 * 1000 ) + 1000;
#ifdef MTA_DEBUG
iTicks /= 60; // Mins to seconds for debug
#endif
// Valid Effect not used for a little while can go
for ( std::map < SString, CEffectTemplate* >::iterator iter = m_ValidMap.begin () ; iter != m_ValidMap.end () ; )
{
CEffectTemplate* pEffectTemplate = iter->second;
if ( pEffectTemplate != pKeepThis && pEffectTemplate->GetTicksSinceLastUsed () > ( bForceDrasticMeasures ? 0 : iTicks ) )
{
OutputDebugLine ( "[Shader] CEffectClonerImpl::MaybeTidyUp: Releasing valid EffectTemplate" );
SAFE_RELEASE( pEffectTemplate );
m_ValidMap.erase ( iter++ );
}
else
++iter;
}
if ( bForceDrasticMeasures )
{
CGraphics::GetSingleton().GetDevice()->EvictManagedResources();
}
}
示例8: MaybeRecordStats
///////////////////////////////////////////////////////////////
//
// CPerfStatRPCPacketUsageImpl::MaybeRecordStats
//
//
//
///////////////////////////////////////////////////////////////
void CPerfStatRPCPacketUsageImpl::MaybeRecordStats ( void )
{
// Someone watching?
if ( m_TimeSinceGetStats.Get () < 10000 )
{
// Time for record update? // Copy and clear once every 5 seconds
long long llTime = GetTickCount64_ ();
if ( llTime >= m_llNextRecordTime )
{
m_llNextRecordTime = Max ( m_llNextRecordTime + 5000, llTime + 5000 / 10 * 9 );
// Save previous sample so we can calc the delta values
memcpy ( m_PrevPacketStatsIn, m_PacketStatsIn, sizeof ( m_PacketStatsIn ) );
memcpy ( m_PacketStatsIn, m_PacketStatsLiveIn, sizeof ( m_PacketStatsIn ) );
memcpy ( m_PrevPacketStatsOut, m_PacketStatsOut, sizeof ( m_PacketStatsOut ) );
memcpy ( m_PacketStatsOut, m_PacketStatsLiveOut, sizeof ( m_PacketStatsOut ) );
if ( m_iStatsCleared == 1 )
{
// Prime if was zeroed
memcpy ( m_PrevPacketStatsIn, m_PacketStatsIn, sizeof ( m_PacketStatsIn ) );
memcpy ( m_PrevPacketStatsOut, m_PacketStatsOut, sizeof ( m_PacketStatsOut ) );
m_iStatsCleared = 2;
}
else
if ( m_iStatsCleared == 2 )
m_iStatsCleared = 0;
}
}
else
{
// No one watching
if ( !m_iStatsCleared )
{
memset ( m_PrevPacketStatsIn, 0, sizeof ( m_PacketStatsIn ) );
memset ( m_PacketStatsIn, 0, sizeof ( m_PacketStatsIn ) );
memset ( m_PrevPacketStatsOut, 0, sizeof ( m_PacketStatsOut ) );
memset ( m_PacketStatsOut, 0, sizeof ( m_PacketStatsOut ) );
m_iStatsCleared = 1;
}
}
}
示例9: HelperGetToucanDLL
static HMODULE HelperGetToucanDLL()
{
if (g_toucan_dll)
return g_toucan_dll;
// Only scan once every five seconds
if ( g_NextToucanDLLSearchTime.Get () < 5000 )
return NULL;
g_NextToucanDLLSearchTime.SetMaxIncrement ( 500, true );
g_NextToucanDLLSearchTime.Reset ();
/*
** We need to enumerate the DLLs loaded to find toucan dll.
** This is done because the toucan dll changes with each update.
** The toucan dll has the following format. "xfire_toucan_{BUILD_NUMBER}.dll"
** We simply try to find a dll w/ the prefix "xfire_toucan"
*/
HANDLE snapshot_handle = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, GetCurrentProcessId());
if (snapshot_handle != INVALID_HANDLE_VALUE)
{
MODULEENTRY32 module_entry;
module_entry.dwSize = sizeof(MODULEENTRY32);
BOOL result = Module32First(snapshot_handle, &module_entry);
char module_name[] = "xfire_toucan";
DWORD module_name_len = sizeof(module_name)-1;
while (result)
{
if (CompareStringA(LOCALE_USER_DEFAULT, NORM_IGNORECASE, module_entry.szModule, module_name_len, module_name, module_name_len) == CSTR_EQUAL)
{
g_toucan_dll = module_entry.hModule;
break;
}
result = Module32Next(snapshot_handle, &module_entry);
}
CloseHandle(snapshot_handle);
}
return g_toucan_dll;
}
示例10: CreateDeviceInsist
////////////////////////////////////////////////
//
// CreateDeviceInsist
//
// Keep trying create device for a little bit
//
////////////////////////////////////////////////
HRESULT CreateDeviceInsist(uint uiMinTries, uint uiTimeout, IDirect3D9* pDirect3D, UINT Adapter, D3DDEVTYPE DeviceType, HWND hFocusWindow, DWORD BehaviorFlags,
D3DPRESENT_PARAMETERS* pPresentationParameters, IDirect3DDevice9** ppReturnedDeviceInterface)
{
HRESULT hResult;
CElapsedTime retryTimer;
uint uiRetryCount = 0;
do
{
ms_uiCreationAttempts++;
hResult = pDirect3D->CreateDevice(Adapter, DeviceType, hFocusWindow, BehaviorFlags, pPresentationParameters, ppReturnedDeviceInterface);
if (hResult == D3D_OK)
{
WriteDebugEvent(SString(" -- CreateDeviceInsist succeeded on try #%d", uiRetryCount + 1));
break;
}
Sleep(1);
} while (++uiRetryCount < uiMinTries || retryTimer.Get() < uiTimeout);
return hResult;
}
示例11: DoPulse
///////////////////////////////////////////////////////////////
//
// CPerfStatDebugTableImpl::DoPulse
//
//
//
///////////////////////////////////////////////////////////////
void CPerfStatDebugTableImpl::DoPulse ( void )
{
// Do remove old once every second
if ( m_TimeSinceRemoveOld.Get () < 1000 )
return;
m_TimeSinceRemoveOld.Reset ();
LOCK_SCOPE ( m_CS );
CTickCount nowTickCount = CTickCount::Now ( true );
// Remove old
for ( std::map < SString, SLineInfo >::iterator iter = m_LineMap.begin () ; iter != m_LineMap.end () ; )
{
SLineInfo& info = iter->second;
if ( info.bHasEndTime && info.endTickCount < nowTickCount )
m_LineMap.erase ( iter++ );
else
++iter;
}
}
示例12: Load
bool CAccountManager::Load( void )
{
//Create a registry result
CRegistryResult result;
//Select all our required information from the accounts database
m_pDatabaseManager->QueryWithResultf ( m_hDbConnection, &result, "SELECT id,name,password,ip,serial,httppass from accounts" );
//Initialize all our variables
m_iAccounts = 0;
bool bNeedsVacuum = false;
CElapsedTime activityTimer;
bool bOutputFeedback = false;
for ( CRegistryResultIterator iter = result->begin() ; iter != result->end() ; ++iter )
{
const CRegistryResultRow& row = *iter;
//Fill User ID, Name & Password (Required data)
int iUserID = static_cast < int > ( row[0].nVal );
SString strName = (const char *)row[1].pVal;
SString strPassword = (const char *)row[2].pVal;
SString strIP = (const char *)row[3].pVal;
SString strSerial = (const char *)row[4].pVal;
SString strHttpPassAppend = (const char *)row[5].pVal;
// Check for overlong names and incorrect escapement
bool bRemoveAccount = false;
bool bChanged = false;
if ( strName.length () > 64 )
{
// Try to repair name
if ( strName.length () <= 256 )
{
strName = strName.Replace ( "\"\"", "\"", true ).substr ( 0, 64 );
bChanged = true;
}
// If name gone doolally or account with this name already exists, remove account
if ( strName.length () > 256 || Get ( strName ) )
{
bNeedsVacuum = true;
bRemoveAccount = true;
CLogger::LogPrintf ( "Removed duplicate or damaged account for %s\n", strName.substr ( 0, 64 ).c_str() );
}
}
// Check for disallowed account names
if ( strName == "*****" || strName == CONSOLE_ACCOUNT_NAME )
bRemoveAccount = true;
// Do account remove if required
if ( bRemoveAccount )
{
m_pDatabaseManager->Execf ( m_hDbConnection, "DELETE FROM accounts WHERE id=?", SQLITE_INTEGER, iUserID );
m_pDatabaseManager->Execf ( m_hDbConnection, "DELETE FROM userdata WHERE userid=?", SQLITE_INTEGER, iUserID );
m_pDatabaseManager->Execf ( m_hDbConnection, "DELETE FROM serialusage WHERE userid=?", SQLITE_INTEGER, iUserID );
continue;
}
//Create a new account with the specified information
CAccount* pAccount = g_pGame->GetAccountManager ()->AddPlayerAccount ( strName, strPassword, iUserID, strIP, strSerial, strHttpPassAppend );
if ( bChanged )
pAccount->SetChanged ( bChanged );
m_iAccounts = std::max ( m_iAccounts, iUserID );
// Feedback for the user
if ( activityTimer.Get() > 5000 )
{
activityTimer.Reset();
bOutputFeedback = true;
CLogger::LogPrintf ( "Reading accounts %d/%d\n", m_List.size(), result->nRows );
}
}
if ( bOutputFeedback )
CLogger::LogPrintf ( "Reading accounts done.\n");
if ( bNeedsVacuum )
m_pDatabaseManager->Execf ( m_hDbConnection, "VACUUM" );
// Save any upgraded accounts
{
CElapsedTime activityTimer;
bool bOutputFeedback = false;
uint uiSaveCount = 0;
for ( CMappedAccountList::const_iterator iter = m_List.begin () ; iter != m_List.end () ; iter++ )
{
CAccount* pAccount = *iter;
if ( pAccount->IsRegistered () && pAccount->HasChanged () && !pAccount->IsConsoleAccount () )
{
uiSaveCount++;
Save ( pAccount, false );
// Feedback for the user
if ( activityTimer.Get() > 5000 )
{
activityTimer.Reset();
bOutputFeedback = true;
CLogger::LogPrintf ( "Saving upgraded accounts %d\n", uiSaveCount );
}
}
}
if ( uiSaveCount > 100 )
//.........这里部分代码省略.........
示例13: GetStats
///////////////////////////////////////////////////////////////
//
// CPerfStatServerInfoImpl::GetStats
//
//
//
///////////////////////////////////////////////////////////////
void CPerfStatServerInfoImpl::GetStats ( CPerfStatResult* pResult, const std::map < SString, int >& strOptionMap, const SString& strFilter )
{
//
// Set option flags
//
bool bHelp = MapContains ( strOptionMap, "h" );
bool bIncludeDebugInfo = MapContains ( strOptionMap, "d" );
//
// Process help
//
if ( bHelp )
{
pResult->AddColumn ( "Server info help" );
pResult->AddRow ()[0] ="Option h - This help";
pResult->AddRow ()[0] ="Option d - Include debug info";
return;
}
// Calculate current rates
long long llIncomingBytesPS = CPerfStatManager::GetPerSecond ( m_llDeltaGameBytesRecv, m_DeltaTickCount.ToLongLong () );
long long llIncomingBytesPSBlocked = CPerfStatManager::GetPerSecond ( m_llDeltaGameBytesRecvBlocked, m_DeltaTickCount.ToLongLong () );
long long llOutgoingBytesPS = CPerfStatManager::GetPerSecond ( m_llDeltaGameBytesSent, m_DeltaTickCount.ToLongLong () );
long long llOutgoingBytesResentPS = CPerfStatManager::GetPerSecond ( m_llDeltaGameBytesResent, m_DeltaTickCount.ToLongLong () );
SString strIncomingPacketsPS = CPerfStatManager::GetPerSecondString ( m_llDeltaGamePacketsRecv, m_DeltaTickCount.ToDouble () );
SString strIncomingPacketsPSBlocked = CPerfStatManager::GetPerSecondString ( m_llDeltaGamePacketsRecvBlocked, m_DeltaTickCount.ToDouble () );
SString strOutgoingPacketsPS = CPerfStatManager::GetPerSecondString ( m_llDeltaGamePacketsSent, m_DeltaTickCount.ToDouble () );
SString strOutgoingMessagesResentPS = CPerfStatManager::GetPerSecondString ( m_llDeltaGameMessagesResent, m_DeltaTickCount.ToDouble () );
// Estimate total network usage
long long llIncomingPacketsPS = CPerfStatManager::GetPerSecond ( m_llDeltaGamePacketsRecv, m_DeltaTickCount.ToLongLong () );
long long llIncomingPacketsPSBlocked = CPerfStatManager::GetPerSecond ( m_llDeltaGamePacketsRecvBlocked, m_DeltaTickCount.ToLongLong () );
long long llOutgoingPacketsPS = CPerfStatManager::GetPerSecond ( m_llDeltaGamePacketsSent, m_DeltaTickCount.ToLongLong () );
long long llNetworkUsageBytesPS = ( llIncomingPacketsPS + llOutgoingPacketsPS ) * UDP_PACKET_OVERHEAD + llIncomingBytesPS + llOutgoingBytesPS;
long long llNetworkUsageBytesPSInclBlocked = ( llIncomingPacketsPS + llIncomingPacketsPSBlocked + llOutgoingPacketsPS ) * UDP_PACKET_OVERHEAD + llIncomingBytesPS + llIncomingBytesPSBlocked + llOutgoingBytesPS;
// Calculate uptime
time_t tUptime = time ( NULL ) - m_tStartTime;
time_t tDays = tUptime / ( 60 * 60 * 24 );
tUptime = tUptime % ( 60 * 60 * 24 );
time_t tHours = tUptime / ( 60 * 60 );
tUptime = tUptime % ( 60 * 60 );
time_t tMinutes = tUptime / ( 60 );
SString strNone;
CMainConfig* pConfig = g_pGame->GetConfig ();
m_InfoList.clear ();
m_StatusList.clear ();
m_OptionsList.clear ();
// Fill info lists
m_InfoList.push_back ( StringPair ( "Platform", CStaticFunctionDefinitions::GetOperatingSystemName () ) );
m_InfoList.push_back ( StringPair ( "Version", CStaticFunctionDefinitions::GetVersionSortable () ) );
m_InfoList.push_back ( StringPair ( "Date", GetLocalTimeString ( true ) ) );
m_InfoList.push_back ( StringPair ( "Uptime", SString ( "%d Days %d Hours %02d Mins", (int)tDays, (int)tHours, (int)tMinutes ) ) );
m_InfoList.push_back ( StringPair ( "Memory", GetProcessMemoryUsage() ) );
if ( !pConfig->GetThreadNetEnabled () )
m_StatusList.push_back ( StringPair ( "Server FPS", SString ( "%d", g_pGame->GetServerFPS () ) ) );
else
m_StatusList.push_back ( StringPair ( "Server FPS sync (logic)", SString ( "%3d (%d)", g_pGame->GetSyncFPS (), g_pGame->GetServerFPS () ) ) );
m_StatusList.push_back ( StringPair ( "Players", SString ( "%d / %d", g_pGame->GetPlayerManager ()->Count (), pConfig->GetMaxPlayers () ) ) );
m_StatusList.push_back ( StringPair ( "Bytes/sec incoming", CPerfStatManager::GetScaledByteString ( llIncomingBytesPS ) ) );
m_StatusList.push_back ( StringPair ( "Bytes/sec outgoing", CPerfStatManager::GetScaledByteString ( llOutgoingBytesPS ) ) );
m_StatusList.push_back ( StringPair ( "Packets/sec incoming", strIncomingPacketsPS ) );
m_StatusList.push_back ( StringPair ( "Packets/sec outgoing", strOutgoingPacketsPS ) );
m_StatusList.push_back ( StringPair ( "Packet loss outgoing", CPerfStatManager::GetPercentString ( llOutgoingBytesResentPS, llOutgoingBytesPS ) ) );
m_StatusList.push_back ( StringPair ( "Approx network usage", CPerfStatManager::GetScaledBitString ( llNetworkUsageBytesPS * 8LL ) + "/s" ) );
if ( pConfig->GetThreadNetEnabled () )
{
m_StatusList.push_back ( StringPair ( "Msg queue incoming", SString ( "%d", CNetBufferWatchDog::ms_uiInResultQueueSize ) ) );
if ( bIncludeDebugInfo )
m_StatusList.push_back ( StringPair ( " finished incoming", SString ( "%d", CNetBufferWatchDog::ms_uiFinishedListSize ) ) );
m_StatusList.push_back ( StringPair ( "Msg queue outgoing", SString ( "%d", CNetBufferWatchDog::ms_uiOutCommandQueueSize ) ) );
if ( bIncludeDebugInfo )
m_StatusList.push_back ( StringPair ( " finished outgoing", SString ( "%d", CNetBufferWatchDog::ms_uiOutResultQueueSize ) ) );
}
if ( ASE* pAse = ASE::GetInstance() )
m_StatusList.push_back ( StringPair ( "ASE queries", SString ( "%d (%d/min)", pAse->GetTotalQueryCount (), pAse->GetQueriesPerMinute () ) ) );
m_OptionsList.push_back ( StringPair ( "MinClientVersion", g_pGame->CalculateMinClientRequirement () ) );
m_OptionsList.push_back ( StringPair ( "RecommendedClientVersion", pConfig->GetRecommendedClientVersion () ) );
m_OptionsList.push_back ( StringPair ( "NetworkEncryptionEnabled", SString ( "%d", pConfig->GetNetworkEncryptionEnabled () ) ) );
m_OptionsList.push_back ( StringPair ( "VoiceEnabled", SString ( "%d", pConfig->IsVoiceEnabled () ) ) );
m_OptionsList.push_back ( StringPair ( "Busy sleep time", SString ( "%d ms", pConfig->GetPendingWorkToDoSleepTime () ) ) );
m_OptionsList.push_back ( StringPair ( "Idle sleep time", SString ( "%d ms", pConfig->GetNoWorkToDoSleepTime () ) ) );
m_OptionsList.push_back ( StringPair ( "BandwidthReductionMode", pConfig->GetSetting ( "bandwidth_reduction" ) ) );
m_OptionsList.push_back ( StringPair ( "LightSyncEnabled", SString ( "%d", g_pBandwidthSettings->bLightSyncEnabled ) ) );
m_OptionsList.push_back ( StringPair ( "ThreadNetEnabled", SString ( "%d", pConfig->GetThreadNetEnabled () ) ) );
const static CTickRateSettings defaultRates;
if ( defaultRates.iPureSync != g_TickRateSettings.iPureSync )
//.........这里部分代码省略.........
示例14: PollCommand
///////////////////////////////////////////////////////////////
//
// CDatabaseJobQueueImpl::PollCommand
//
// Find result for previous command
// Returns false if result not ready.
//
///////////////////////////////////////////////////////////////
bool CDatabaseJobQueueImpl::PollCommand ( CDbJobData* pJobData, uint uiTimeout )
{
bool bFound = false;
uint uiTotalWaitTime = 0;
uint uiWaitTimeWarnThresh = TICKS_FROM_SECONDS( 60 );
shared.m_Mutex.Lock ();
while ( true )
{
// Should not be called for ignored results
dassert ( !pJobData->result.bIgnoreResult );
// Should not be called for collected results
dassert ( pJobData->stage != EJobStage::FINISHED );
// See if result has come in yet
if ( ListContains( shared.m_ResultQueue, pJobData ) )
{
ListRemove( shared.m_ResultQueue, pJobData );
pJobData->stage = EJobStage::FINISHED;
MapInsert ( m_FinishedList, pJobData );
// Do callback incase any cleanup is needed
if ( pJobData->HasCallback () )
{
shared.m_Mutex.Unlock ();
pJobData->ProcessCallback ();
shared.m_Mutex.Lock ();
}
bFound = true;
}
if ( bFound || uiTimeout == 0 )
{
shared.m_Mutex.Unlock ();
break;
}
CElapsedTime timer;
shared.m_Mutex.Wait (std::min( uiTimeout, 1000U ) );
uint uiDelta = (uint)timer.Get() + 1;
uiTotalWaitTime += uiDelta;
// If not infinite, subtract time actually waited
if ( uiTimeout != (uint)-1 )
{
if ( uiDelta < uiTimeout )
uiTimeout -= uiDelta;
else
uiTimeout = 0;
}
// Issue warning if it's taking a long time
if ( uiTotalWaitTime > uiWaitTimeWarnThresh )
{
shared.m_Mutex.Unlock ();
g_pGame->GetScriptDebugging()->LogWarning( pJobData->m_LuaDebugInfo, "dbPoll is waiting a long time (%d seconds so far). [Query: %s]", uiTotalWaitTime / 1000, *pJobData->GetCommandStringForLog() );
shared.m_Mutex.Lock ();
uiWaitTimeWarnThresh += TICKS_FROM_SECONDS( 60 );
}
}
// Make sure if wait was infinite, we have a result
assert ( uiTimeout != (uint)-1 || bFound );
return bFound;
}