File tree Expand file tree Collapse file tree 3 files changed +42
-9
lines changed Expand file tree Collapse file tree 3 files changed +42
-9
lines changed Original file line number Diff line number Diff line change @@ -1019,18 +1019,30 @@ bool CLIENT_STATE::poll_slow_events() {
1019
1019
}
1020
1020
#endif
1021
1021
1022
- bool old_user_active = user_active;
1022
+ // there are 2 reasons to get idle state:
1023
+ // if needed for computing prefs,
1024
+ // or (on Mac) we were started by screensaver
1025
+ //
1026
+ bool get_idle_state = global_prefs.need_idle_state ;
1027
+ #ifdef __APPLE__
1028
+ if (started_by_screensaver) get_idle_state = true ;
1029
+ #endif
1030
+ long idle_time;
1031
+ if (get_idle_state) {
1032
+ bool old_user_active = user_active;
1023
1033
#ifdef ANDROID
1024
- user_active = device_status.user_active ;
1034
+ user_active = device_status.user_active ;
1025
1035
#else
1026
- long idle_time = host_info.user_idle_time (check_all_logins);
1027
- user_active = idle_time < global_prefs.idle_time_to_run * 60 ;
1036
+ idle_time = host_info.user_idle_time (check_all_logins);
1037
+ user_active = idle_time < global_prefs.idle_time_to_run * 60 ;
1028
1038
#endif
1029
-
1030
- if (user_active != old_user_active) {
1031
- set_n_usable_cpus ();
1032
- // if niu_max_ncpus_pct pref is set, # usable CPUs may change
1033
- request_schedule_cpus (user_active?" Not idle" :" Idle" );
1039
+ if (user_active != old_user_active) {
1040
+ set_n_usable_cpus ();
1041
+ // if niu_max_ncpus_pct pref is set, # usable CPUs may change
1042
+ request_schedule_cpus (user_active?" Not idle" :" Idle" );
1043
+ }
1044
+ } else {
1045
+ user_active = false ; // shouldn't matter what it is
1034
1046
}
1035
1047
1036
1048
#if 0
Original file line number Diff line number Diff line change @@ -675,6 +675,9 @@ void CLIENT_STATE::read_global_prefs(
675
675
file_xfers->set_bandwidth_limits (true );
676
676
file_xfers->set_bandwidth_limits (false );
677
677
#endif
678
+
679
+ bool have_gpu = coprocs.n_rsc > 1 ;
680
+ global_prefs.need_idle_state = global_prefs.get_need_idle_state (have_gpu);
678
681
print_global_prefs ();
679
682
request_schedule_cpus (" Prefs update" );
680
683
request_work_fetch (" Prefs update" );
@@ -815,6 +818,11 @@ void CLIENT_STATE::print_global_prefs() {
815
818
allowed_disk_usage (total_disk_usage)/GIGA
816
819
);
817
820
#endif
821
+ if (!global_prefs.need_idle_state ) {
822
+ msg_printf (NULL , MSG_INFO,
823
+ " - Preferences don't depend on whether computer is in use"
824
+ );
825
+ }
818
826
msg_printf (NULL , MSG_INFO,
819
827
" - (to change preferences, visit a project web site or select 'Options / Computing preferences...' in the Manager)"
820
828
);
Original file line number Diff line number Diff line change @@ -197,6 +197,8 @@ struct GLOBAL_PREFS {
197
197
bool host_specific;
198
198
// an account manager can set this; if set, don't propagate
199
199
bool override_file_present;
200
+ bool need_idle_state;
201
+ // whether idle state makes any difference
200
202
201
203
GLOBAL_PREFS ();
202
204
void defaults ();
@@ -214,6 +216,17 @@ struct GLOBAL_PREFS {
214
216
return cpu_scheduling_period_minutes*60 ;
215
217
}
216
218
static double parse_mod_time (const char *);
219
+ bool get_need_idle_state (bool have_gpu) {
220
+ // is any pref set that causes different behavior if user is active?
221
+ //
222
+ if (!run_if_user_active) return true ;
223
+ if (have_gpu && !run_gpu_if_user_active) return true ;
224
+ if (suspend_if_no_recent_input) return true ;
225
+ if (niu_cpu_usage_limit && niu_cpu_usage_limit != cpu_usage_limit) return true ;
226
+ if (niu_max_ncpus_pct && niu_max_ncpus_pct != max_ncpus_pct) return true ;
227
+ if (niu_suspend_cpu_usage && niu_suspend_cpu_usage != suspend_cpu_usage) return true ;
228
+ return false ;
229
+ }
217
230
};
218
231
219
232
#endif
You can’t perform that action at this time.
0 commit comments