Moved setting of previous process times to block where background mining is started, and added an explicit sleep in that block to wait for some mining to occur.

This commit is contained in:
Dion Ahmetaj 2017-02-02 12:30:33 -05:00 committed by Dion Ahmetaj
parent 21a1e0252f
commit 2937fdbbbf

View file

@ -579,19 +579,6 @@ namespace cryptonote
{
// figure out if we need to stop, and monitor mining usage
// previous is uninitialized
if(previous_process_time == 0)
{
// get some starting data ..
if(!get_system_times(prev_total_time, prev_idle_time))
LOG_ERROR(__func__ << " : get_system_times call failed");
if(!get_process_time(previous_process_time))
LOG_ERROR(__func__ << " : get_process_time call failed!");
continue;
}
// If we get here, then previous values are initialized.
// Let's get some current data for comparison.
@ -660,6 +647,16 @@ namespace cryptonote
MGINFO(__func__ << " : cpu is " << unsigned(idle_percentage) << "% idle, idle threshold is " << unsigned(get_idle_threshold()) << "\%, ac power : " << on_ac_power << ", background mining started, good luck!");
m_is_background_mining_started = true;
m_is_background_mining_started_cond.notify_all();
// Wait for a little mining to happen ..
boost::this_thread::sleep_for(boost::chrono::seconds( 1 ));
// Starting data ...
if(!get_process_time(previous_process_time))
{
m_is_background_mining_started = false;
LOG_ERROR(__func__ << " : get_process_time call failed!");
}
}
prev_total_time = current_total_time;