Sysinfo Gadget: Thread Lifetime vs Object Lifetime management.

This cleans up how sysinfo manages object vs thread lifetimes.  If thread is still alive dependent on aspects that need to be freed in the gadget removal process, it defers that cleanup from the remove callback to the thread end callback.  As for the combination sysinfo gadget, each gadget inside of sysinfo will set a done flag alerting that the cleanup of the combination gadget can happen once all threads are done.
This fixes T5694
This commit is contained in:
Stephen 'Okra' Houston 2017-07-13 19:16:50 -05:00
parent 739c1aa4b8
commit 804f038f71
9 changed files with 425 additions and 62 deletions

View File

@ -579,9 +579,14 @@ _batman_removed_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_data)
#endif
evas_object_event_callback_del_full(inst->o_main, EVAS_CALLBACK_DEL, sysinfo_batman_remove, data);
evas_object_smart_callback_del_full(e_gadget_site_get(inst->o_main), "gadget_removed",
_batman_removed_cb, inst);
sysinfo_config->items = eina_list_remove(sysinfo_config->items, inst->cfg);
if (inst->cfg->id >= 0)
sysinfo_instances = eina_list_remove(sysinfo_instances, inst);
E_FREE(inst->cfg);
E_FREE(inst);
}
void
@ -608,6 +613,19 @@ sysinfo_batman_remove(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNU
(void) inst;
_batman_fallback_stop();
#endif
inst->cfg->batman.done = EINA_TRUE;
if (inst->cfg->esm == E_SYSINFO_MODULE_SYSINFO)
{
if (inst->cfg->memusage.done && inst->cfg->thermal.done &&
inst->cfg->netstatus.done && inst->cfg->cpuclock.done && inst->cfg->cpumonitor.done)
{
sysinfo_config->items = eina_list_remove(sysinfo_config->items, inst->cfg);
if (inst->cfg->id >= 0)
sysinfo_instances = eina_list_remove(sysinfo_instances, inst);
E_FREE(inst->cfg);
E_FREE(inst);
}
}
}
static void
@ -656,6 +674,7 @@ sysinfo_batman_create(Evas_Object *parent, Instance *inst)
inst->cfg->batman.time_left = -2;
inst->cfg->batman.have_battery = -2;
inst->cfg->batman.have_power = -2;
inst->cfg->batman.done = EINA_FALSE;
inst->cfg->batman.o_gadget = elm_layout_add(parent);
e_theme_edje_object_set(inst->cfg->batman.o_gadget, "base/theme/gadget/batman",
@ -727,6 +746,7 @@ batman_create(Evas_Object *parent, int *id, E_Gadget_Site_Orient orient EINA_UNU
inst = E_NEW(Instance, 1);
inst->cfg = _conf_item_get(id);
*id = inst->cfg->id;
inst->cfg->batman.done = EINA_FALSE;
inst->o_main = elm_box_add(parent);
E_EXPAND(inst->o_main);
evas_object_data_set(inst->o_main, "Instance", inst);

View File

@ -880,6 +880,36 @@ _cpuclock_cb_frequency_check_end(void *data, Ecore_Thread *th EINA_UNUSED)
{
Thread_Config *thc = data;
e_powersave_sleeper_free(thc->sleeper);
if (thc->inst->cfg->cpuclock.defer)
{
if (thc->inst->cfg->cpuclock.handler)
ecore_event_handler_del(thc->inst->cfg->cpuclock.handler);
if (thc->inst->cfg->cpuclock.governor)
eina_stringshare_del(thc->inst->cfg->cpuclock.governor);
E_FREE_FUNC(thc->inst->cfg->cpuclock.status, _cpuclock_status_free);
thc->inst->cfg->cpuclock.defer = EINA_FALSE;
thc->inst->cfg->cpuclock.done = EINA_TRUE;
if (thc->inst->cfg->esm == E_SYSINFO_MODULE_CPUCLOCK)
{
sysinfo_config->items = eina_list_remove(sysinfo_config->items, thc->inst->cfg);
if (thc->inst->cfg->id >= 0)
sysinfo_instances = eina_list_remove(sysinfo_instances, thc->inst);
E_FREE(thc->inst->cfg);
E_FREE(thc->inst);
}
else
{
if (thc->inst->cfg->memusage.done && thc->inst->cfg->thermal.done &&
thc->inst->cfg->netstatus.done && thc->inst->cfg->cpumonitor.done && thc->inst->cfg->batman.done)
{
sysinfo_config->items = eina_list_remove(sysinfo_config->items, thc->inst->cfg);
if (thc->inst->cfg->id >= 0)
sysinfo_instances = eina_list_remove(sysinfo_instances, thc->inst);
E_FREE(thc->inst->cfg);
E_FREE(thc->inst);
}
}
}
E_FREE_FUNC(thc, free);
}
@ -943,28 +973,31 @@ _cpuclock_removed_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_data)
E_FREE_FUNC(inst->cfg->cpuclock.popup, evas_object_del);
if (inst->cfg->cpuclock.popup)
E_FREE_FUNC(inst->cfg->cpuclock.popup, evas_object_del);
if (inst->cfg->cpuclock.configure)
E_FREE_FUNC(inst->cfg->cpuclock.configure, evas_object_del);
if (inst->cfg->cpuclock.handler)
ecore_event_handler_del(inst->cfg->cpuclock.handler);
EINA_LIST_FREE(inst->cfg->cpuclock.handlers, handler)
ecore_event_handler_del(handler);
evas_object_event_callback_del_full(inst->o_main, EVAS_CALLBACK_DEL, sysinfo_cpuclock_remove, data);
evas_object_smart_callback_del_full(e_gadget_site_get(inst->o_main), "gadget_removed",
_cpuclock_removed_cb, inst);
if (inst->cfg->cpuclock.frequency_check_thread)
{
inst->cfg->cpuclock.defer = EINA_TRUE;
ecore_thread_cancel(inst->cfg->cpuclock.frequency_check_thread);
inst->cfg->cpuclock.frequency_check_thread = NULL;
return;
}
if (inst->cfg->cpuclock.governor)
if (inst->cfg->cpuclock.handler)
ecore_event_handler_del(inst->cfg->cpuclock.handler);
if (inst->cfg->cpuclock.governor)
eina_stringshare_del(inst->cfg->cpuclock.governor);
E_FREE_FUNC(inst->cfg->cpuclock.status, _cpuclock_status_free);
evas_object_event_callback_del_full(inst->o_main, EVAS_CALLBACK_DEL, sysinfo_cpuclock_remove, data);
sysinfo_config->items = eina_list_remove(sysinfo_config->items, inst->cfg);
if (inst->cfg->id >= 0)
sysinfo_instances = eina_list_remove(sysinfo_instances, inst);
E_FREE(inst->cfg);
E_FREE(inst);
}
void
@ -977,24 +1010,37 @@ sysinfo_cpuclock_remove(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_U
E_FREE_FUNC(inst->cfg->cpuclock.popup, evas_object_del);
if (inst->cfg->cpuclock.popup)
E_FREE_FUNC(inst->cfg->cpuclock.popup, evas_object_del);
if (inst->cfg->cpuclock.configure)
E_FREE_FUNC(inst->cfg->cpuclock.configure, evas_object_del);
EINA_LIST_FREE(inst->cfg->cpuclock.handlers, handler)
ecore_event_handler_del(handler);
if (inst->cfg->cpuclock.frequency_check_thread)
{
inst->cfg->cpuclock.defer = EINA_TRUE;
ecore_thread_cancel(inst->cfg->cpuclock.frequency_check_thread);
inst->cfg->cpuclock.frequency_check_thread = NULL;
return;
}
if (inst->cfg->cpuclock.handler)
ecore_event_handler_del(inst->cfg->cpuclock.handler);
EINA_LIST_FREE(inst->cfg->cpuclock.handlers, handler)
ecore_event_handler_del(handler);
if (inst->cfg->cpuclock.frequency_check_thread)
{
ecore_thread_cancel(inst->cfg->cpuclock.frequency_check_thread);
inst->cfg->cpuclock.frequency_check_thread = NULL;
}
if (inst->cfg->cpuclock.governor)
if (inst->cfg->cpuclock.governor)
eina_stringshare_del(inst->cfg->cpuclock.governor);
E_FREE_FUNC(inst->cfg->cpuclock.status, _cpuclock_status_free);
inst->cfg->cpuclock.done = EINA_TRUE;
if (inst->cfg->esm == E_SYSINFO_MODULE_SYSINFO)
{
if (inst->cfg->memusage.done && inst->cfg->thermal.done &&
inst->cfg->netstatus.done && inst->cfg->cpumonitor.done && inst->cfg->batman.done)
{
sysinfo_config->items = eina_list_remove(sysinfo_config->items, inst->cfg);
if (inst->cfg->id >= 0)
sysinfo_instances = eina_list_remove(sysinfo_instances, inst);
E_FREE(inst->cfg);
E_FREE(inst);
}
}
}
static void
@ -1059,6 +1105,8 @@ sysinfo_cpuclock_create(Evas_Object *parent, Instance *inst)
{
Eina_List *l = NULL;
inst->cfg->cpuclock.defer = EINA_FALSE;
inst->cfg->cpuclock.done = EINA_FALSE;
if (inst->cfg->cpuclock.pstate_min == 0) inst->cfg->cpuclock.pstate_min = 1;
if (inst->cfg->cpuclock.pstate_max == 0) inst->cfg->cpuclock.pstate_max = 101;
@ -1144,6 +1192,8 @@ cpuclock_create(Evas_Object *parent, int *id, E_Gadget_Site_Orient orient EINA_U
inst = E_NEW(Instance, 1);
inst->cfg = _conf_item_get(id);
*id = inst->cfg->id;
inst->cfg->cpuclock.defer = EINA_FALSE;
inst->cfg->cpuclock.done = EINA_FALSE;
inst->o_main = elm_box_add(parent);
E_EXPAND(inst->o_main);
evas_object_data_set(inst->o_main, "Instance", inst);

View File

@ -197,7 +197,39 @@ static void
_cpumonitor_cb_usage_check_end(void *data, Ecore_Thread *th EINA_UNUSED)
{
Thread_Config *thc = data;
CPU_Core *core;
e_powersave_sleeper_free(thc->sleeper);
if (thc->inst->cfg->cpumonitor.defer)
{
EINA_LIST_FREE(thc->inst->cfg->cpumonitor.cores, core)
{
evas_object_del(core->layout);
E_FREE_FUNC(core, free);
}
thc->inst->cfg->cpumonitor.defer = EINA_FALSE;
thc->inst->cfg->cpumonitor.done = EINA_TRUE;
if (thc->inst->cfg->esm == E_SYSINFO_MODULE_CPUMONITOR)
{
sysinfo_config->items = eina_list_remove(sysinfo_config->items, thc->inst->cfg);
if (thc->inst->cfg->id >= 0)
sysinfo_instances = eina_list_remove(sysinfo_instances, thc->inst);
E_FREE(thc->inst->cfg);
E_FREE(thc->inst);
}
else
{
if (thc->inst->cfg->memusage.done && thc->inst->cfg->thermal.done &&
thc->inst->cfg->netstatus.done && thc->inst->cfg->cpuclock.done && thc->inst->cfg->batman.done)
{
sysinfo_config->items = eina_list_remove(sysinfo_config->items, thc->inst->cfg);
if (thc->inst->cfg->id >= 0)
sysinfo_instances = eina_list_remove(sysinfo_instances, thc->inst);
E_FREE(thc->inst->cfg);
E_FREE(thc->inst);
}
}
}
E_FREE_FUNC(thc, free);
}
@ -313,22 +345,30 @@ _cpumonitor_removed_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_dat
E_FREE_FUNC(inst->cfg->cpumonitor.popup, evas_object_del);
if (inst->cfg->cpumonitor.configure)
E_FREE_FUNC(inst->cfg->cpumonitor.configure, evas_object_del);
if (inst->cfg->cpumonitor.usage_check_thread)
{
ecore_thread_cancel(inst->cfg->cpumonitor.usage_check_thread);
inst->cfg->cpumonitor.usage_check_thread = NULL;
}
EINA_LIST_FREE(inst->cfg->cpumonitor.handlers, handler)
ecore_event_handler_del(handler);
EINA_LIST_FREE(inst->cfg->cpumonitor.cores, core)
evas_object_smart_callback_del_full(e_gadget_site_get(inst->o_main), "gadget_removed",
_cpumonitor_removed_cb, inst);
evas_object_event_callback_del_full(inst->o_main, EVAS_CALLBACK_DEL, sysinfo_cpumonitor_remove, data);
if (inst->cfg->cpumonitor.usage_check_thread)
{
inst->cfg->cpumonitor.defer = EINA_TRUE;
ecore_thread_cancel(inst->cfg->cpumonitor.usage_check_thread);
inst->cfg->cpumonitor.usage_check_thread = NULL;
return;
}
EINA_LIST_FREE(inst->cfg->cpumonitor.cores, core)
{
evas_object_del(core->layout);
E_FREE_FUNC(core, free);
}
evas_object_event_callback_del_full(inst->o_main, EVAS_CALLBACK_DEL, sysinfo_cpumonitor_remove, data);
sysinfo_config->items = eina_list_remove(sysinfo_config->items, inst->cfg);
if (inst->cfg->id >= 0)
sysinfo_instances = eina_list_remove(sysinfo_instances, inst);
E_FREE(inst->cfg);
E_FREE(inst);
}
void
@ -342,18 +382,33 @@ sysinfo_cpumonitor_remove(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA
E_FREE_FUNC(inst->cfg->cpumonitor.popup, evas_object_del);
if (inst->cfg->cpumonitor.configure)
E_FREE_FUNC(inst->cfg->cpumonitor.configure, evas_object_del);
if (inst->cfg->cpumonitor.usage_check_thread)
{
ecore_thread_cancel(inst->cfg->cpumonitor.usage_check_thread);
inst->cfg->cpumonitor.usage_check_thread = NULL;
}
EINA_LIST_FREE(inst->cfg->cpumonitor.handlers, handler)
ecore_event_handler_del(handler);
if (inst->cfg->cpumonitor.usage_check_thread)
{
inst->cfg->cpumonitor.defer = EINA_TRUE;
ecore_thread_cancel(inst->cfg->cpumonitor.usage_check_thread);
inst->cfg->cpumonitor.usage_check_thread = NULL;
return;
}
EINA_LIST_FREE(inst->cfg->cpumonitor.cores, core)
{
evas_object_del(core->layout);
E_FREE_FUNC(core, free);
}
inst->cfg->cpumonitor.done = EINA_TRUE;
if (inst->cfg->esm == E_SYSINFO_MODULE_SYSINFO)
{
if (inst->cfg->memusage.done && inst->cfg->thermal.done &&
inst->cfg->netstatus.done && inst->cfg->cpuclock.done && inst->cfg->batman.done)
{
sysinfo_config->items = eina_list_remove(sysinfo_config->items, inst->cfg);
if (inst->cfg->id >= 0)
sysinfo_instances = eina_list_remove(sysinfo_instances, inst);
E_FREE(inst->cfg);
E_FREE(inst);
}
}
}
static void
@ -400,6 +455,13 @@ _cpumonitor_created_cb(void *data, Evas_Object *obj, void *event_data EINA_UNUSE
Evas_Object *
sysinfo_cpumonitor_create(Evas_Object *parent, Instance *inst)
{
inst->cfg->cpumonitor.defer = EINA_FALSE;
inst->cfg->cpumonitor.done = EINA_FALSE;
inst->cfg->cpumonitor.total = 0;
inst->cfg->cpumonitor.idle = 0;
inst->cfg->cpumonitor.percent = 0;
inst->cfg->cpumonitor.popup = NULL;
inst->cfg->cpumonitor.configure = NULL;
inst->cfg->cpumonitor.o_gadget = elm_table_add(parent);
E_EXPAND(inst->cfg->cpumonitor.o_gadget);
E_FILL(inst->cfg->cpumonitor.o_gadget);
@ -470,6 +532,8 @@ cpumonitor_create(Evas_Object *parent, int *id, E_Gadget_Site_Orient orient EINA
inst = E_NEW(Instance, 1);
inst->cfg = _conf_item_get(id);
*id = inst->cfg->id;
inst->cfg->cpumonitor.defer = EINA_FALSE;
inst->cfg->cpumonitor.done = EINA_FALSE;
inst->cfg->cpumonitor.total = 0;
inst->cfg->cpumonitor.idle = 0;
inst->cfg->cpumonitor.percent = 0;

View File

@ -308,6 +308,31 @@ _memusage_cb_usage_check_end(void *data, Ecore_Thread *th EINA_UNUSED)
{
Thread_Config *thc = data;
e_powersave_sleeper_free(thc->sleeper);
if (thc->inst->cfg->memusage.defer)
{
thc->inst->cfg->memusage.defer = EINA_FALSE;
thc->inst->cfg->memusage.done = EINA_TRUE;
if (thc->inst->cfg->esm == E_SYSINFO_MODULE_MEMUSAGE)
{
sysinfo_config->items = eina_list_remove(sysinfo_config->items, thc->inst->cfg);
if (thc->inst->cfg->id >= 0)
sysinfo_instances = eina_list_remove(sysinfo_instances, thc->inst);
E_FREE(thc->inst->cfg);
E_FREE(thc->inst);
}
else
{
if (thc->inst->cfg->cpumonitor.done && thc->inst->cfg->thermal.done &&
thc->inst->cfg->netstatus.done && thc->inst->cfg->cpuclock.done && thc->inst->cfg->batman.done)
{
sysinfo_config->items = eina_list_remove(sysinfo_config->items, thc->inst->cfg);
if (thc->inst->cfg->id >= 0)
sysinfo_instances = eina_list_remove(sysinfo_instances, thc->inst);
E_FREE(thc->inst->cfg);
E_FREE(thc->inst);
}
}
}
E_FREE_FUNC(thc, free);
}
@ -393,22 +418,29 @@ _memusage_removed_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_data)
if (inst->o_main != event_data) return;
if (inst->cfg->memusage.popup)
E_FREE_FUNC(inst->cfg->memusage.popup, evas_object_del);
if (inst->cfg->memusage.configure)
E_FREE_FUNC(inst->cfg->memusage.configure, evas_object_del);
if (inst->cfg->memusage.usage_check_thread)
{
ecore_thread_cancel(inst->cfg->memusage.usage_check_thread);
inst->cfg->memusage.usage_check_thread = NULL;
}
EINA_LIST_FREE(inst->cfg->memusage.handlers, handler)
ecore_event_handler_del(handler);
evas_object_smart_callback_del_full(e_gadget_site_get(inst->o_main), "gadget_removed",
_memusage_removed_cb, inst);
evas_object_event_callback_del_full(inst->o_main, EVAS_CALLBACK_DEL,
sysinfo_memusage_remove, data);
EINA_LIST_FREE(inst->cfg->memusage.handlers, handler)
ecore_event_handler_del(handler);
if (inst->cfg->memusage.usage_check_thread)
{
inst->cfg->memusage.defer = EINA_TRUE;
ecore_thread_cancel(inst->cfg->memusage.usage_check_thread);
inst->cfg->memusage.usage_check_thread = NULL;
return;
}
sysinfo_config->items = eina_list_remove(sysinfo_config->items, inst->cfg);
if (inst->cfg->id >= 0)
sysinfo_instances = eina_list_remove(sysinfo_instances, inst);
E_FREE(inst->cfg);
E_FREE(inst);
}
void
@ -423,11 +455,26 @@ sysinfo_memusage_remove(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_U
E_FREE_FUNC(inst->cfg->memusage.configure, evas_object_del);
if (inst->cfg->memusage.usage_check_thread)
{
inst->cfg->memusage.defer = EINA_TRUE;
ecore_thread_cancel(inst->cfg->memusage.usage_check_thread);
inst->cfg->memusage.usage_check_thread = NULL;
return;
}
EINA_LIST_FREE(inst->cfg->memusage.handlers, handler)
ecore_event_handler_del(handler);
inst->cfg->thermal.done = EINA_TRUE;
if (inst->cfg->esm == E_SYSINFO_MODULE_SYSINFO)
{
if (inst->cfg->memusage.done && inst->cfg->cpumonitor.done &&
inst->cfg->netstatus.done && inst->cfg->cpuclock.done && inst->cfg->batman.done)
{
sysinfo_config->items = eina_list_remove(sysinfo_config->items, inst->cfg);
if (inst->cfg->id >= 0)
sysinfo_instances = eina_list_remove(sysinfo_instances, inst);
E_FREE(inst->cfg);
E_FREE(inst);
}
}
}
static void
@ -470,6 +517,19 @@ _memusage_created_cb(void *data, Evas_Object *obj, void *event_data EINA_UNUSED)
Evas_Object *
sysinfo_memusage_create(Evas_Object *parent, Instance *inst)
{
inst->cfg->memusage.defer = EINA_FALSE;
inst->cfg->memusage.done = EINA_FALSE;
inst->cfg->memusage.mem_percent = 0;
inst->cfg->memusage.swp_percent = 0;
inst->cfg->memusage.mem_total = 0;
inst->cfg->memusage.mem_used = 0;
inst->cfg->memusage.mem_cached = 0;
inst->cfg->memusage.mem_buffers = 0;
inst->cfg->memusage.mem_shared = 0;
inst->cfg->memusage.swp_total = 0;
inst->cfg->memusage.swp_used = 0;
inst->cfg->memusage.popup = NULL;
inst->cfg->memusage.configure = NULL;
inst->cfg->memusage.o_gadget = elm_layout_add(parent);
e_theme_edje_object_set(inst->cfg->memusage.o_gadget,
"base/theme/gadget/memusage",
@ -539,6 +599,8 @@ memusage_create(Evas_Object *parent, int *id, E_Gadget_Site_Orient orient EINA_U
inst = E_NEW(Instance, 1);
inst->cfg = _conf_item_get(id);
*id = inst->cfg->id;
inst->cfg->memusage.defer = EINA_FALSE;
inst->cfg->memusage.done = EINA_FALSE;
inst->cfg->memusage.mem_percent = 0;
inst->cfg->memusage.swp_percent = 0;
inst->cfg->memusage.mem_total = 0;

View File

@ -88,6 +88,7 @@ sysinfo_init(void)
ci->batman.desktop_notifications = 0;
ci->batman.popup = NULL;
ci->batman.configure = NULL;
ci->batman.done = EINA_FALSE;
ci->thermal.poll_interval = 128;
ci->thermal.low = 30;
ci->thermal.high = 80;
@ -97,6 +98,8 @@ sysinfo_init(void)
ci->thermal.units = CELSIUS;
ci->thermal.popup = NULL;
ci->thermal.configure = NULL;
ci->thermal.defer = EINA_FALSE;
ci->thermal.done = EINA_FALSE;
ci->cpuclock.poll_interval = 32;
ci->cpuclock.restore_governor = 0;
ci->cpuclock.auto_powersave = 1;
@ -106,17 +109,23 @@ sysinfo_init(void)
ci->cpuclock.pstate_max = 101;
ci->cpuclock.popup = NULL;
ci->cpuclock.configure = NULL;
ci->cpuclock.defer = EINA_FALSE;
ci->cpuclock.done = EINA_FALSE;
ci->cpumonitor.poll_interval = 32;
ci->cpumonitor.total = 0;
ci->cpumonitor.idle = 0;
ci->cpumonitor.percent = 0;
ci->cpumonitor.popup = NULL;
ci->cpumonitor.configure = NULL;
ci->cpumonitor.defer = EINA_FALSE;
ci->cpumonitor.done = EINA_FALSE;
ci->memusage.poll_interval = 32;
ci->memusage.mem_percent = 0;
ci->memusage.swp_percent = 0;
ci->memusage.popup = NULL;
ci->memusage.configure = NULL;
ci->memusage.defer = EINA_FALSE;
ci->memusage.done = EINA_FALSE;
ci->netstatus.poll_interval = 32;
ci->netstatus.automax = EINA_TRUE;
ci->netstatus.receive_units = NETSTATUS_UNIT_BYTES;
@ -133,6 +142,8 @@ sysinfo_init(void)
ci->netstatus.outstring = NULL;
ci->netstatus.popup = NULL;
ci->netstatus.configure = NULL;
ci->netstatus.defer = EINA_FALSE;
ci->netstatus.done = EINA_FALSE;
E_CONFIG_LIMIT(ci->batman.poll_interval, 4, 4096);
E_CONFIG_LIMIT(ci->batman.alert, 0, 60);

View File

@ -168,6 +168,33 @@ _netstatus_cb_usage_check_end(void *data, Ecore_Thread *th EINA_UNUSED)
{
Thread_Config *thc = data;
e_powersave_sleeper_free(thc->sleeper);
if (thc->inst->cfg->netstatus.defer)
{
E_FREE_FUNC(thc->inst->cfg->netstatus.instring, eina_stringshare_del);
E_FREE_FUNC(thc->inst->cfg->netstatus.outstring, eina_stringshare_del);
thc->inst->cfg->netstatus.defer = EINA_FALSE;
thc->inst->cfg->netstatus.done = EINA_TRUE;
if (thc->inst->cfg->esm == E_SYSINFO_MODULE_NETSTATUS)
{
sysinfo_config->items = eina_list_remove(sysinfo_config->items, thc->inst->cfg);
if (thc->inst->cfg->id >= 0)
sysinfo_instances = eina_list_remove(sysinfo_instances, thc->inst);
E_FREE(thc->inst->cfg);
E_FREE(thc->inst);
}
else
{
if (thc->inst->cfg->memusage.done && thc->inst->cfg->thermal.done &&
thc->inst->cfg->cpumonitor.done && thc->inst->cfg->cpuclock.done && thc->inst->cfg->batman.done)
{
sysinfo_config->items = eina_list_remove(sysinfo_config->items, thc->inst->cfg);
if (thc->inst->cfg->id >= 0)
sysinfo_instances = eina_list_remove(sysinfo_instances, thc->inst);
E_FREE(thc->inst->cfg);
E_FREE(thc->inst);
}
}
}
E_FREE_FUNC(thc, free);
}
@ -231,19 +258,26 @@ _netstatus_removed_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_data
E_FREE_FUNC(inst->cfg->netstatus.popup, evas_object_del);
if (inst->cfg->netstatus.configure)
E_FREE_FUNC(inst->cfg->netstatus.configure, evas_object_del);
if (inst->cfg->netstatus.usage_check_thread)
{
ecore_thread_cancel(inst->cfg->netstatus.usage_check_thread);
inst->cfg->netstatus.usage_check_thread = NULL;
}
evas_object_smart_callback_del_full(e_gadget_site_get(inst->o_main), "gadget_removed",
_netstatus_removed_cb, inst);
evas_object_event_callback_del_full(inst->o_main, EVAS_CALLBACK_DEL, sysinfo_netstatus_remove, data);
EINA_LIST_FREE(inst->cfg->netstatus.handlers, handler)
ecore_event_handler_del(handler);
if (inst->cfg->netstatus.usage_check_thread)
{
inst->cfg->netstatus.defer = EINA_TRUE;
ecore_thread_cancel(inst->cfg->netstatus.usage_check_thread);
inst->cfg->netstatus.usage_check_thread = NULL;
return;
}
E_FREE_FUNC(inst->cfg->netstatus.instring, eina_stringshare_del);
E_FREE_FUNC(inst->cfg->netstatus.outstring, eina_stringshare_del);
evas_object_event_callback_del_full(inst->o_main, EVAS_CALLBACK_DEL, sysinfo_netstatus_remove, data);
sysinfo_config->items = eina_list_remove(sysinfo_config->items, inst->cfg);
if (inst->cfg->id >= 0)
sysinfo_instances = eina_list_remove(sysinfo_instances, inst);
E_FREE(inst->cfg);
E_FREE(inst);
}
void
@ -256,15 +290,30 @@ sysinfo_netstatus_remove(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_
E_FREE_FUNC(inst->cfg->netstatus.popup, evas_object_del);
if (inst->cfg->netstatus.configure)
E_FREE_FUNC(inst->cfg->netstatus.configure, evas_object_del);
if (inst->cfg->netstatus.usage_check_thread)
{
ecore_thread_cancel(inst->cfg->netstatus.usage_check_thread);
inst->cfg->netstatus.usage_check_thread = NULL;
}
EINA_LIST_FREE(inst->cfg->netstatus.handlers, handler)
ecore_event_handler_del(handler);
if (inst->cfg->netstatus.usage_check_thread)
{
inst->cfg->netstatus.defer = EINA_TRUE;
ecore_thread_cancel(inst->cfg->netstatus.usage_check_thread);
inst->cfg->netstatus.usage_check_thread = NULL;
return;
}
E_FREE_FUNC(inst->cfg->netstatus.instring, eina_stringshare_del);
E_FREE_FUNC(inst->cfg->netstatus.outstring, eina_stringshare_del);
inst->cfg->netstatus.done = EINA_TRUE;
if (inst->cfg->esm == E_SYSINFO_MODULE_SYSINFO)
{
if (inst->cfg->memusage.done && inst->cfg->thermal.done &&
inst->cfg->cpumonitor.done && inst->cfg->cpuclock.done && inst->cfg->batman.done)
{
sysinfo_config->items = eina_list_remove(sysinfo_config->items, inst->cfg);
if (inst->cfg->id >= 0)
sysinfo_instances = eina_list_remove(sysinfo_instances, inst);
E_FREE(inst->cfg);
E_FREE(inst);
}
}
}
static void
@ -300,6 +349,17 @@ _netstatus_created_cb(void *data, Evas_Object *obj, void *event_data EINA_UNUSED
Evas_Object *
sysinfo_netstatus_create(Evas_Object *parent, Instance *inst)
{
inst->cfg->netstatus.defer = EINA_FALSE;
inst->cfg->netstatus.done = EINA_FALSE;
inst->cfg->netstatus.in = 0;
inst->cfg->netstatus.out = 0;
inst->cfg->netstatus.incurrent = 0;
inst->cfg->netstatus.outcurrent = 0;
inst->cfg->netstatus.inpercent = 0;
inst->cfg->netstatus.outpercent = 0;
inst->cfg->netstatus.instring = NULL;
inst->cfg->netstatus.outstring = NULL;
inst->cfg->netstatus.popup = NULL;
inst->cfg->netstatus.o_gadget = elm_layout_add(parent);
e_theme_edje_object_set(inst->cfg->netstatus.o_gadget, "base/theme/gadget/netstatus",
"e/gadget/netstatus/main");
@ -366,6 +426,8 @@ netstatus_create(Evas_Object *parent, int *id, E_Gadget_Site_Orient orient EINA_
inst = E_NEW(Instance, 1);
inst->cfg = _conf_item_get(id);
*id = inst->cfg->id;
inst->cfg->netstatus.defer = EINA_FALSE;
inst->cfg->netstatus.done = EINA_FALSE;
inst->cfg->netstatus.in = 0;
inst->cfg->netstatus.out = 0;
inst->cfg->netstatus.incurrent = 0;

View File

@ -15,18 +15,27 @@ _sysinfo_removed_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_data)
sysinfo_memusage_remove(inst, NULL, NULL, NULL);
sysinfo_netstatus_remove(inst, NULL, NULL, NULL);
evas_object_smart_callback_del_full(e_gadget_site_get(obj), "gadget_removed", _sysinfo_removed_cb, inst);
evas_object_event_callback_del_full(inst->o_main, EVAS_CALLBACK_DEL, _sysinfo_deleted_cb, data);
sysinfo_config->items = eina_list_remove(sysinfo_config->items, inst->cfg);
E_FREE(inst->cfg);
if (inst && inst->cfg)
{
if (inst->cfg->batman.done && inst->cfg->memusage.done && inst->cfg->thermal.done &&
inst->cfg->cpumonitor.done && inst->cfg->cpuclock.done && inst->cfg->netstatus.done)
{
sysinfo_config->items = eina_list_remove(sysinfo_config->items, inst->cfg);
if (inst->cfg->id >= 0)
sysinfo_instances = eina_list_remove(sysinfo_instances, inst);
E_FREE(inst->cfg);
E_FREE(inst);
}
}
}
static void
_sysinfo_deleted_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj, void *event_data EINA_UNUSED)
_sysinfo_deleted_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_data EINA_UNUSED)
{
Instance *inst = data;
evas_object_smart_callback_del_full(e_gadget_site_get(obj), "gadget_removed", _sysinfo_removed_cb, inst);
sysinfo_batman_remove(inst, NULL, NULL, NULL);
sysinfo_thermal_remove(inst, NULL, NULL, NULL);
sysinfo_cpuclock_remove(inst, NULL, NULL, NULL);
@ -98,6 +107,7 @@ _conf_item_get(int *id)
ci->batman.desktop_notifications = 0;
ci->batman.popup = NULL;
ci->batman.configure = NULL;
ci->batman.done = EINA_FALSE;
ci->thermal.poll_interval = 128;
ci->thermal.low = 30;
ci->thermal.high = 80;
@ -106,6 +116,8 @@ _conf_item_get(int *id)
ci->thermal.units = CELSIUS;
ci->thermal.popup = NULL;
ci->thermal.configure = NULL;
ci->thermal.done = EINA_FALSE;
ci->thermal.defer = EINA_FALSE;
ci->cpuclock.poll_interval = 32;
ci->cpuclock.restore_governor = 0;
ci->cpuclock.auto_powersave = 1;
@ -115,6 +127,10 @@ _conf_item_get(int *id)
ci->cpuclock.pstate_max = 101;
ci->cpuclock.popup = NULL;
ci->cpuclock.configure = NULL;
ci->cpuclock.done = EINA_FALSE;
ci->cpuclock.defer = EINA_FALSE;
ci->cpumonitor.done = EINA_FALSE;
ci->cpumonitor.defer = EINA_FALSE;
ci->cpumonitor.poll_interval = 32;
ci->cpumonitor.total = 0;
ci->cpumonitor.idle = 0;
@ -126,6 +142,8 @@ _conf_item_get(int *id)
ci->memusage.swp_percent = 0;
ci->memusage.popup = NULL;
ci->memusage.configure = NULL;
ci->memusage.done = EINA_FALSE;
ci->memusage.defer = EINA_FALSE;
ci->netstatus.poll_interval = 32;
ci->netstatus.in = 0;
ci->netstatus.out = 0;
@ -144,6 +162,8 @@ _conf_item_get(int *id)
ci->netstatus.outmax = 0;
ci->netstatus.receive_units = NETSTATUS_UNIT_BYTES;
ci->netstatus.send_units = NETSTATUS_UNIT_BYTES;
ci->netstatus.done = EINA_FALSE;
ci->netstatus.defer = EINA_FALSE;
sysinfo_config->items = eina_list_append(sysinfo_config->items, ci);

View File

@ -145,6 +145,7 @@ struct _Config_Item
int have_power;
int desktop_notifications;
Eina_List *handlers;
Eina_Bool done;
#ifdef HAVE_EEZE
Eeze_Udev_Watch *acwatch;
Eeze_Udev_Watch *batwatch;
@ -174,6 +175,8 @@ struct _Config_Item
Eina_Bool have_temp:1;
Eina_List *handlers;
Eina_Bool defer;
Eina_Bool done;
} thermal;
struct
{
@ -192,6 +195,8 @@ struct _Config_Item
Ecore_Thread *frequency_check_thread;
Ecore_Event_Handler *handler;
Eina_List *handlers;
Eina_Bool defer;
Eina_Bool done;
} cpuclock;
struct
{
@ -209,6 +214,8 @@ struct _Config_Item
Ecore_Thread *usage_check_thread;
Eina_List *cores;
Eina_List *handlers;
Eina_Bool defer;
Eina_Bool done;
} cpumonitor;
struct
{
@ -227,6 +234,8 @@ struct _Config_Item
unsigned long swp_used;
Ecore_Thread *usage_check_thread;
Eina_List *handlers;
Eina_Bool defer;
Eina_Bool done;
} memusage;
struct
{
@ -250,6 +259,8 @@ struct _Config_Item
Eina_Stringshare *outstring;
Ecore_Thread *usage_check_thread;
Eina_List *handlers;
Eina_Bool defer;
Eina_Bool done;
} netstatus;
struct {
Evas_Object *o_batman;

View File

@ -133,7 +133,7 @@ _thermal_check_fallback(void *data, Ecore_Thread *th)
static void
_thermal_check_notify(void *data, Ecore_Thread *th, void *msg)
{
Tempthread *tth = data;
Tempthread *tth = data;
Instance *inst = tth->inst;
int temp = (int)((long)msg);
if (th != inst->cfg->thermal.th) return;
@ -143,7 +143,35 @@ _thermal_check_notify(void *data, Ecore_Thread *th, void *msg)
static void
_thermal_check_done(void *data, Ecore_Thread *th EINA_UNUSED)
{
_thermal_thread_free(data);
TempThread *tth = data;
Instance *inst = tth->inst;
if (inst->cfg->thermal.defer)
{
_thermal_thread_free(tth);
inst->cfg->thermal.defer = EINA_FALSE;
inst->cfg->thermal.done = EINA_TRUE;
if (inst->cfg->esm == E_SYSINFO_MODULE_THERMAL)
{
sysinfo_config->items = eina_list_remove(sysinfo_config->items, inst->cfg);
if (inst->cfg->id >= 0)
sysinfo_instances = eina_list_remove(sysinfo_instances, inst);
E_FREE(inst->cfg);
E_FREE(inst);
}
else
{
if (inst->cfg->memusage.done && inst->cfg->cpumonitor.done &&
inst->cfg->netstatus.done && inst->cfg->cpuclock.done && inst->cfg->batman.done)
{
sysinfo_config->items = eina_list_remove(sysinfo_config->items, inst->cfg);
if (inst->cfg->id >= 0)
sysinfo_instances = eina_list_remove(sysinfo_instances, inst);
E_FREE(inst->cfg);
E_FREE(inst);
}
}
}
}
#endif
@ -299,8 +327,6 @@ _thermal_config_updated(Instance *inst)
static void
_thermal_face_shutdown(Instance *inst)
{
if (inst->cfg->thermal.th) ecore_thread_cancel(inst->cfg->thermal.th);
if (inst->cfg->thermal.sensor_name) eina_stringshare_del(inst->cfg->thermal.sensor_name);
#if defined(HAVE_EEZE)
if (inst->cfg->thermal.poller)
{
@ -308,6 +334,7 @@ _thermal_face_shutdown(Instance *inst)
_thermal_thread_free(inst->cfg->thermal.tth);
}
#endif
if (inst->cfg->thermal.sensor_name) eina_stringshare_del(inst->cfg->thermal.sensor_name);
}
static void
@ -341,12 +368,22 @@ _thermal_removed_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_data)
E_FREE_FUNC(inst->cfg->thermal.configure, evas_object_del);
EINA_LIST_FREE(inst->cfg->thermal.handlers, handler)
ecore_event_handler_del(handler);
_thermal_face_shutdown(inst);
evas_object_event_callback_del_full(inst->o_main, EVAS_CALLBACK_DEL, sysinfo_thermal_remove, data);
evas_object_smart_callback_del_full(e_gadget_site_get(inst->o_main), "gadget_removed",
_thermal_removed_cb, inst);
if (inst->cfg->thermal.th)
{
inst->cfg->thermal.defer = EINA_TRUE;
ecore_thread_cancel(inst->cfg->thermal.th);
inst->cfg->thermal.th = NULL;
return;
}
_thermal_face_shutdown(inst);
sysinfo_config->items = eina_list_remove(sysinfo_config->items, inst->cfg);
if (inst->cfg->id >= 0)
sysinfo_instances = eina_list_remove(sysinfo_instances, inst);
E_FREE(inst->cfg);
E_FREE(inst);
}
void
@ -362,8 +399,28 @@ sysinfo_thermal_remove(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UN
if (inst->cfg->thermal.configure)
E_FREE_FUNC(inst->cfg->thermal.configure, evas_object_del);
EINA_LIST_FREE(inst->cfg->thermal.handlers, handler)
ecore_event_handler_del(handler);
ecore_event_handler_del(handler);
if (inst->cfg->thermal.th)
{
inst->cfg->thermal.defer = EINA_TRUE;
ecore_thread_cancel(inst->cfg->thermal.th);
inst->cfg->thermal.th = NULL;
return;
}
_thermal_face_shutdown(inst);
inst->cfg->thermal.done = EINA_TRUE;
if (inst->cfg->esm == E_SYSINFO_MODULE_SYSINFO)
{
if (inst->cfg->memusage.done && inst->cfg->cpumonitor.done &&
inst->cfg->netstatus.done && inst->cfg->cpuclock.done && inst->cfg->batman.done)
{
sysinfo_config->items = eina_list_remove(sysinfo_config->items, inst->cfg);
if (inst->cfg->id >= 0)
sysinfo_instances = eina_list_remove(sysinfo_instances, inst);
E_FREE(inst->cfg);
E_FREE(inst);
}
}
}
static void
@ -376,6 +433,8 @@ _thermal_created_cb(void *data, Evas_Object *obj, void *event_data EINA_UNUSED)
inst->cfg->thermal.temp = 900;
inst->cfg->thermal.have_temp = EINA_FALSE;
inst->cfg->thermal.defer = EINA_FALSE;
inst->cfg->thermal.done = EINA_FALSE;
inst->cfg->thermal.o_gadget = elm_layout_add(inst->o_main);
if (orient == E_GADGET_SITE_ORIENT_VERTICAL)
@ -406,6 +465,8 @@ sysinfo_thermal_create(Evas_Object *parent, Instance *inst)
{
inst->cfg->thermal.temp = 900;
inst->cfg->thermal.have_temp = EINA_FALSE;
inst->cfg->thermal.defer = EINA_FALSE;
inst->cfg->thermal.done = EINA_FALSE;
inst->cfg->thermal.o_gadget = elm_layout_add(parent);
e_theme_edje_object_set(inst->cfg->thermal.o_gadget, "base/theme/gadget/thermal",
@ -467,6 +528,8 @@ thermal_create(Evas_Object *parent, int *id, E_Gadget_Site_Orient orient EINA_UN
inst = E_NEW(Instance, 1);
inst->cfg = _conf_item_get(id);
*id = inst->cfg->id;
inst->cfg->thermal.defer = EINA_FALSE;
inst->cfg->thermal.done = EINA_FALSE;
inst->o_main = elm_box_add(parent);
E_EXPAND(inst->o_main);
evas_object_data_set(inst->o_main, "Instance", inst);