Revert "Sysinfo gadgets: Revert all uses of faulty e_powersave_sleeper."

This reverts commit f8e17b67e4.
This commit is contained in:
Carsten Haitzler 2017-09-12 09:08:04 +09:00
parent 4bc8df4cbb
commit 14e1583cd0
7 changed files with 26 additions and 11 deletions

View File

@ -16,6 +16,7 @@ struct _Thread_Config
{ {
int interval; int interval;
Instance *inst; Instance *inst;
E_Powersave_Sleeper *sleeper;
}; };
typedef struct _Pstate_Config Pstate_Config; typedef struct _Pstate_Config Pstate_Config;
@ -839,7 +840,7 @@ _cpuclock_cb_frequency_check_main(void *data, Ecore_Thread *th)
else else
_cpuclock_status_free(status); _cpuclock_status_free(status);
if (ecore_thread_check(th)) break; if (ecore_thread_check(th)) break;
usleep((1000000.0 / 8.0) * (double)thc->interval); e_powersave_sleeper_sleep(thc->sleeper, thc->interval);
if (ecore_thread_check(th)) break; if (ecore_thread_check(th)) break;
} }
} }
@ -893,6 +894,7 @@ _cpuclock_cb_frequency_check_end(void *data, Ecore_Thread *th EINA_UNUSED)
{ {
Thread_Config *thc = data; Thread_Config *thc = data;
e_powersave_sleeper_free(thc->sleeper);
E_FREE(thc); E_FREE(thc);
} }
@ -910,6 +912,7 @@ _cpuclock_poll_interval_update(Instance *inst)
if (thc) if (thc)
{ {
thc->inst = inst; thc->inst = inst;
thc->sleeper = e_powersave_sleeper_new();
thc->interval = inst->cfg->cpuclock.poll_interval; thc->interval = inst->cfg->cpuclock.poll_interval;
inst->cfg->cpuclock.frequency_check_thread = inst->cfg->cpuclock.frequency_check_thread =
ecore_thread_feedback_run(_cpuclock_cb_frequency_check_main, ecore_thread_feedback_run(_cpuclock_cb_frequency_check_main,

View File

@ -10,6 +10,7 @@ struct _Thread_Config
unsigned long total; unsigned long total;
unsigned long idle; unsigned long idle;
Instance *inst; Instance *inst;
E_Powersave_Sleeper *sleeper;
Eina_List *cores; Eina_List *cores;
}; };
@ -172,7 +173,7 @@ _cpumonitor_cb_usage_check_main(void *data, Ecore_Thread *th)
#endif #endif
ecore_thread_feedback(th, NULL); ecore_thread_feedback(th, NULL);
if (ecore_thread_check(th)) break; if (ecore_thread_check(th)) break;
usleep((1000000.0 / 8.0) * (double)thc->interval); e_powersave_sleeper_sleep(thc->sleeper, thc->interval);
if (ecore_thread_check(th)) break; if (ecore_thread_check(th)) break;
} }
} }
@ -196,6 +197,7 @@ _cpumonitor_cb_usage_check_end(void *data, Ecore_Thread *th EINA_UNUSED)
Thread_Config *thc = data; Thread_Config *thc = data;
CPU_Core *core; CPU_Core *core;
e_powersave_sleeper_free(thc->sleeper);
EINA_LIST_FREE(thc->cores, core) EINA_LIST_FREE(thc->cores, core)
E_FREE(core); E_FREE(core);
E_FREE(thc); E_FREE(thc);
@ -305,6 +307,7 @@ _cpumonitor_config_updated(Instance *inst)
thc->idle = 0; thc->idle = 0;
thc->percent = 0; thc->percent = 0;
thc->interval = inst->cfg->cpumonitor.poll_interval; thc->interval = inst->cfg->cpumonitor.poll_interval;
thc->sleeper = e_powersave_sleeper_new();
#if defined(__FreeBSD__) || defined(__DragonFly__) || defined(__OpenBSD__) #if defined(__FreeBSD__) || defined(__DragonFly__) || defined(__OpenBSD__)
thc->num_cores = _cpumonitor_sysctl_getcores(); thc->num_cores = _cpumonitor_sysctl_getcores();
#else #else

View File

@ -15,6 +15,7 @@ struct _Thread_Config
unsigned long mem_shared; unsigned long mem_shared;
unsigned long swp_total; unsigned long swp_total;
unsigned long swp_used; unsigned long swp_used;
E_Powersave_Sleeper *sleeper;
}; };
static void static void
@ -293,7 +294,7 @@ _memusage_cb_usage_check_main(void *data, Ecore_Thread *th)
ecore_thread_feedback(th, NULL); ecore_thread_feedback(th, NULL);
if (ecore_thread_check(th)) break; if (ecore_thread_check(th)) break;
usleep((1000000.0 / 8.0) * (double)thc->interval); e_powersave_sleeper_sleep(thc->sleeper, thc->interval);
if (ecore_thread_check(th)) break; if (ecore_thread_check(th)) break;
} }
} }
@ -302,6 +303,7 @@ static void
_memusage_cb_usage_check_end(void *data, Ecore_Thread *th EINA_UNUSED) _memusage_cb_usage_check_end(void *data, Ecore_Thread *th EINA_UNUSED)
{ {
Thread_Config *thc = data; Thread_Config *thc = data;
e_powersave_sleeper_free(thc->sleeper);
E_FREE(thc); E_FREE(thc);
} }
@ -372,6 +374,7 @@ _memusage_config_updated(Instance *inst)
if (thc) if (thc)
{ {
thc->inst = inst; thc->inst = inst;
thc->sleeper = e_powersave_sleeper_new();
thc->interval = inst->cfg->memusage.poll_interval; thc->interval = inst->cfg->memusage.poll_interval;
thc->mem_percent = 0; thc->mem_percent = 0;
thc->swp_percent = 0; thc->swp_percent = 0;

View File

@ -19,6 +19,7 @@ struct _Thread_Config
unsigned long outcurrent; unsigned long outcurrent;
unsigned long outmax; unsigned long outmax;
Eina_Stringshare *outstring; Eina_Stringshare *outstring;
E_Powersave_Sleeper *sleeper;
}; };
static void static void
@ -180,7 +181,7 @@ _netstatus_cb_usage_check_main(void *data, Ecore_Thread *th)
eina_stringshare_replace(&thc->outstring, rout); eina_stringshare_replace(&thc->outstring, rout);
ecore_thread_feedback(th, NULL); ecore_thread_feedback(th, NULL);
if (ecore_thread_check(th)) break; if (ecore_thread_check(th)) break;
usleep((1000000.0 / 8.0) * (double)thc->interval); e_powersave_sleeper_sleep(thc->sleeper, thc->interval);
if (ecore_thread_check(th)) break; if (ecore_thread_check(th)) break;
} }
} }
@ -204,6 +205,7 @@ static void
_netstatus_cb_usage_check_end(void *data, Ecore_Thread *th EINA_UNUSED) _netstatus_cb_usage_check_end(void *data, Ecore_Thread *th EINA_UNUSED)
{ {
Thread_Config *thc = data; Thread_Config *thc = data;
e_powersave_sleeper_free(thc->sleeper);
E_FREE_FUNC(thc->instring, eina_stringshare_del); E_FREE_FUNC(thc->instring, eina_stringshare_del);
E_FREE_FUNC(thc->outstring, eina_stringshare_del); E_FREE_FUNC(thc->outstring, eina_stringshare_del);
E_FREE(thc); E_FREE(thc);
@ -259,6 +261,7 @@ _netstatus_config_updated(Instance *inst)
if (thc) if (thc)
{ {
thc->inst = inst; thc->inst = inst;
thc->sleeper = e_powersave_sleeper_new();
thc->interval = inst->cfg->netstatus.poll_interval; thc->interval = inst->cfg->netstatus.poll_interval;
thc->in = 0; thc->in = 0;
thc->inmax = inst->cfg->netstatus.inmax; thc->inmax = inst->cfg->netstatus.inmax;

View File

@ -18,7 +18,7 @@ _netstatus_proc_getrstatus(Eina_Bool automax,
if (!*last_checked) if (!*last_checked)
*last_checked = current; *last_checked = current;
if ((current - *last_checked) < 1) else if ((current - *last_checked) < 1)
return; return;
else else
diff = current - *last_checked; diff = current - *last_checked;
@ -73,15 +73,15 @@ _netstatus_proc_gettstatus(Eina_Bool automax,
int percent = 0; int percent = 0;
char buf[4096], dummys[64]; char buf[4096], dummys[64];
FILE *f; FILE *f;
time_t last = *last_checked, current = time(NULL); time_t current = time(NULL);
time_t diff = 0; time_t diff = 0;
if (!last) if (!*last_checked)
*last_checked = current; *last_checked = current;
else if ((current - last) < 1) else if ((current - *last_checked) < 1)
return; return;
else else
diff = current - last; diff = current - *last_checked;
f = fopen("/proc/net/dev", "r"); f = fopen("/proc/net/dev", "r");
if (f) if (f)
{ {

View File

@ -76,6 +76,7 @@ struct _Tempthread
const char *sensor_name; const char *sensor_name;
const char *sensor_path; const char *sensor_path;
void *extn; void *extn;
E_Powersave_Sleeper *sleeper;
#if defined(HAVE_EEZE) #if defined(HAVE_EEZE)
Eina_List *tempdevs; Eina_List *tempdevs;
#endif #endif

View File

@ -14,6 +14,7 @@ _thermal_thread_free(Tempthread *tth)
EINA_LIST_FREE(tth->tempdevs, s) EINA_LIST_FREE(tth->tempdevs, s)
eina_stringshare_del(s); eina_stringshare_del(s);
#endif #endif
e_powersave_sleeper_free(tth->sleeper);
E_FREE(tth->extn); E_FREE(tth->extn);
E_FREE(tth); E_FREE(tth);
} }
@ -98,7 +99,7 @@ _thermal_check_sysctl(void *data, Ecore_Thread *th)
temp = thermal_sysctl_get(tth); temp = thermal_sysctl_get(tth);
if (ptemp != temp) ecore_thread_feedback(th, (void *)((long)temp)); if (ptemp != temp) ecore_thread_feedback(th, (void *)((long)temp));
ptemp = temp; ptemp = temp;
usleep((1000000.0 / 8.0) * (double)thc->poll_interval); e_powersave_sleeper_sleep(tth->sleeper, tth->poll_interval);
if (ecore_thread_check(th)) break; if (ecore_thread_check(th)) break;
} }
} }
@ -117,7 +118,7 @@ _thermal_check_fallback(void *data, Ecore_Thread *th)
temp = thermal_fallback_get(tth); temp = thermal_fallback_get(tth);
if (ptemp != temp) ecore_thread_feedback(th, (void *)((long)temp)); if (ptemp != temp) ecore_thread_feedback(th, (void *)((long)temp));
ptemp = temp; ptemp = temp;
usleep((1000000.0 / 8.0) * (double)thc->poll_interval); e_powersave_sleeper_sleep(tth->sleeper, tth->poll_interval);
if (ecore_thread_check(th)) break; if (ecore_thread_check(th)) break;
} }
} }
@ -273,6 +274,7 @@ _thermal_config_updated(Instance *inst)
tth->poll_interval = inst->cfg->thermal.poll_interval; tth->poll_interval = inst->cfg->thermal.poll_interval;
tth->sensor_type = inst->cfg->thermal.sensor_type; tth->sensor_type = inst->cfg->thermal.sensor_type;
tth->inst = inst; tth->inst = inst;
tth->sleeper = e_powersave_sleeper_new();
if (inst->cfg->thermal.sensor_name) if (inst->cfg->thermal.sensor_name)
tth->sensor_name = eina_stringshare_add(inst->cfg->thermal.sensor_name); tth->sensor_name = eina_stringshare_add(inst->cfg->thermal.sensor_name);