Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Check for idle time settings that preventing computing #4634

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 38 additions & 12 deletions clientgui/DlgAdvPreferences.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ void CDlgAdvPreferences::ReadPreferenceSettings() {
if (prefs.max_ncpus_pct == 0.0) prefs.max_ncpus_pct = 100.0;
DisplayValue(prefs.max_ncpus_pct, m_txtProcUseProcessors);

//cpu limit
//cpu limit
// 0 means "no restriction" but we don't use a checkbox here
if (prefs.cpu_usage_limit == 0.0) prefs.cpu_usage_limit = 100.0;
DisplayValue(prefs.cpu_usage_limit, m_txtProcUseCPUTime);
Expand Down Expand Up @@ -469,7 +469,7 @@ bool CDlgAdvPreferences::SavePreferencesSettings() {
//
m_txtNoRecentInput->GetValue().ToDouble(&td);
prefs.suspend_if_no_recent_input = RoundToHundredths(td);
mask.suspend_if_no_recent_input = true;
mask.suspend_if_no_recent_input = true;

//
if (m_chkMaxLoad->IsChecked()) {
Expand Down Expand Up @@ -688,6 +688,7 @@ bool CDlgAdvPreferences::ValidateInput() {
wxString invMsgLimit10 = _("Number must be between 0 and 10");
wxString invMsgLimit100 = _("Number must be between 0 and 100");
wxString invMsgLimit1_100 = _("Number must be between 1 and 100");
wxString invMsgIdle = _("Warning: 'When to suspend' time settings will not allow any CPU and/or GPU tasks to compute. Reduce time to compute after idle or increase time to suspend after idle.");
wxString buffer;
double startTime, endTime;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I recommend to move these two variables close to using - to line 816 (844) to avoid redundant creation if code will hit one of the return false;. And I suggest to initialize them by default

Suggested change
double startTime, endTime;
double startTime{0.0}, endTime{0.0};

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand. Because the "suspend when no mouse/keyboard input in last" variable is always enabled, I should just use the usual "buffer" variable for "bufferNRI". BufferPIF can be initialized in the conditional statement.

Your suggested change is not related to the code I modified, but I see your point, I can initialize these variables.


Expand All @@ -704,20 +705,45 @@ bool CDlgAdvPreferences::ValidateInput() {
return false;
}

if(m_txtProcIdleFor->IsEnabled()) {
buffer = m_txtProcIdleFor->GetValue();
if(!IsValidFloatValueBetween(buffer, 0, 9999999999999.99)) {
ShowErrorMessage(invMsgFloat,m_txtProcIdleFor);
return false;
}
}

buffer = m_txtNoRecentInput->GetValue();
if (!IsValidFloatValueBetween(buffer, 0, 9999999999999.99)) {
// Validate No Recent Input
//
wxString bufferNRI = m_txtNoRecentInput->GetValue(); // variable to store No Recent Input string.
if (!IsValidFloatValueBetween(bufferNRI, 0, 9999999999999.99)) {
ShowErrorMessage(invMsgFloat, m_txtNoRecentInput);
return false;
}

// If the processor is to suspend when the computer is not idle,
// this will first validate the input.
//
if (m_txtProcIdleFor->IsEnabled()) {
wxString bufferPIF = m_txtProcIdleFor->GetValue(); // variable to store Processor Idle For string.
if (!IsValidFloatValueBetween(bufferPIF, 0, 9999999999999.99)) {
ShowErrorMessage(invMsgFloat, m_txtProcIdleFor);
return false;
}
// It is possible that the computer will not process tasks
// if the time for no recent input is nonzero and is less than or
// equal to the idle time before computing resumes (ProcIdleFor).
// This will check that condition and return an error.
//
double valueNRI;
bufferNRI.ToDouble(&valueNRI);
// Since these values will be stored rounded to the hundredth, it should
// be evaluated that way.
//
valueNRI = RoundToHundredths(valueNRI);
if (valueNRI > 0) {
double valuePIF;
bufferPIF.ToDouble(&valuePIF);
valuePIF = RoundToHundredths(valuePIF);
if (valueNRI <= valuePIF) {
ShowErrorMessage(invMsgIdle, m_txtNoRecentInput);
return false;
}
}
}

if (m_chkMaxLoad->IsChecked()) {
buffer = m_txtMaxLoad->GetValue();
if(!IsValidFloatValueBetween(buffer, 1.0, 100.0)) {
Expand Down