Fixed: IfActions not fired when measure is disabled

This commit is contained in:
Birunthan Mohanathas
2012-05-30 09:46:11 +03:00
parent 8fb0be30d4
commit 9623766a61
32 changed files with 125 additions and 214 deletions

View File

@ -117,10 +117,8 @@ void CMeasureCPU::ReadConfig(CConfigParser& parser, const WCHAR* section)
** Updates the current CPU utilization value.
**
*/
bool CMeasureCPU::Update()
void CMeasureCPU::UpdateValue()
{
if (!CMeasure::PreUpdate()) return false;
if (m_Processor == 0)
{
BOOL status;
@ -128,7 +126,7 @@ bool CMeasureCPU::Update()
// get new CPU's idle/kernel/user time
status = GetSystemTimes(&ftIdleTime, &ftKernelTime, &ftUserTime);
if (status == 0) return false;
if (status == 0) return;
CalcUsage(Ft2Double(ftIdleTime),
Ft2Double(ftKernelTime) + Ft2Double(ftUserTime));
@ -146,9 +144,7 @@ bool CMeasureCPU::Update()
ULONG size = 0;
status = c_NtQuerySystemInformation(SystemProcessorPerformanceInformation, buf, bufSize, &size);
if (status == STATUS_SUCCESS || status != STATUS_INFO_LENGTH_MISMATCH) break;
else // status == STATUS_INFO_LENGTH_MISMATCH
if (status == STATUS_INFO_LENGTH_MISMATCH)
{
if (size == 0) // Returned required buffer size is always 0 on Windows 2000/XP.
{
@ -176,37 +172,33 @@ bool CMeasureCPU::Update()
delete [] buf;
buf = new BYTE[bufSize];
}
else
{
break;
}
++loop;
}
while (loop < 5);
if (status != STATUS_SUCCESS) // failed
if (status == STATUS_SUCCESS)
{
delete [] buf;
return false;
if (bufSize != c_BufferSize)
{
// Store the new buffer size
c_BufferSize = bufSize;
}
SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION* systemPerfInfo = (SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION*)buf;
int processor = m_Processor - 1;
CalcUsage(Li2Double(systemPerfInfo[processor].IdleTime),
Li2Double(systemPerfInfo[processor].KernelTime) + Li2Double(systemPerfInfo[processor].UserTime));
}
if (bufSize != c_BufferSize)
{
// Store the new buffer size
c_BufferSize = bufSize;
}
SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION* systemPerfInfo = (SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION*)buf;
int processor = m_Processor - 1;
CalcUsage(Li2Double(systemPerfInfo[processor].IdleTime),
Li2Double(systemPerfInfo[processor].KernelTime) + Li2Double(systemPerfInfo[processor].UserTime));
delete [] buf;
}
else
{
return false;
}
return PostUpdate();
}
/*