ui: no need to expose thread ptr

This commit is contained in:
Alastair Poole 2020-12-30 02:41:44 +00:00
parent e43d0109b7
commit 8108e4f724
4 changed files with 23 additions and 23 deletions

View File

@ -42,7 +42,6 @@ typedef struct Ui
struct struct
{ {
Evas_Object *win; Evas_Object *win;
Ecore_Thread *thread;
int width; int width;
int height; int height;
} cpu; } cpu;
@ -52,7 +51,6 @@ typedef struct Ui
Evas_Object *win; Evas_Object *win;
int width; int width;
int height; int height;
Ecore_Thread *thread;
Eina_Bool zfs_mounted; Eina_Bool zfs_mounted;
} mem; } mem;
@ -68,7 +66,6 @@ typedef struct Ui
Evas_Object *win; Evas_Object *win;
int width; int width;
int height; int height;
Ecore_Thread *thread;
} sensors; } sensors;
} Ui; } Ui;

View File

@ -10,6 +10,8 @@ typedef struct {
typedef struct { typedef struct {
Ui *ui; Ui *ui;
Ecore_Thread *thread;
Evas_Object *bg; Evas_Object *bg;
Evas_Object *obj; Evas_Object *obj;
@ -350,8 +352,8 @@ _win_del_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void
// on deletion of window, cancel thread, free animate data and set cpu // on deletion of window, cancel thread, free animate data and set cpu
// dialog handle to null // dialog handle to null
ecore_thread_cancel(ui->cpu.thread); ecore_thread_cancel(ad->thread);
ecore_thread_wait(ui->cpu.thread, 0.5); ecore_thread_wait(ad->thread, 0.5);
EINA_LIST_FREE(ad->explainers, exp) EINA_LIST_FREE(ad->explainers, exp)
{ {
@ -679,11 +681,11 @@ _graph(Ui *ui, Evas_Object *parent)
evas_object_event_callback_add(ui->cpu.win, EVAS_CALLBACK_DEL, _win_del_cb, ad); evas_object_event_callback_add(ui->cpu.win, EVAS_CALLBACK_DEL, _win_del_cb, ad);
// run a feedback thread that sends feedback to the mainloop // run a feedback thread that sends feedback to the mainloop
ui->cpu.thread = ecore_thread_feedback_run(_core_times_main_cb, ad->thread = ecore_thread_feedback_run(_core_times_main_cb,
_core_times_feedback_cb, _core_times_feedback_cb,
NULL, NULL,
NULL, NULL,
ad, EINA_TRUE); ad, EINA_TRUE);
} }
static void static void

View File

@ -4,6 +4,7 @@
#include <Elementary.h> #include <Elementary.h>
typedef struct { typedef struct {
Ecore_Thread *thread;
Evas_Object *win; Evas_Object *win;
Evas_Object *bg; Evas_Object *bg;
@ -354,8 +355,8 @@ _win_del_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj,
Ui_Data *pd = data; Ui_Data *pd = data;
Ui *ui = pd->ui; Ui *ui = pd->ui;
ecore_thread_cancel(ui->mem.thread); ecore_thread_cancel(pd->thread);
ecore_thread_wait(ui->mem.thread, 0.5); ecore_thread_wait(pd->thread, 0.5);
evas_object_del(obj); evas_object_del(obj);
ui->mem.win = NULL; ui->mem.win = NULL;
@ -505,9 +506,9 @@ ui_win_memory_add(Ui *ui, Evas_Object *parent)
evas_object_event_callback_add(win, EVAS_CALLBACK_DEL, _win_del_cb, pd); evas_object_event_callback_add(win, EVAS_CALLBACK_DEL, _win_del_cb, pd);
evas_object_show(win); evas_object_show(win);
ui->mem.thread = ecore_thread_feedback_run(_mem_usage_main_cb, pd->thread = ecore_thread_feedback_run(_mem_usage_main_cb,
_mem_usage_feedback_cb, _mem_usage_feedback_cb,
NULL, NULL,
NULL, NULL,
pd, EINA_TRUE); pd, EINA_TRUE);
} }

View File

@ -3,6 +3,7 @@
typedef struct typedef struct
{ {
Ecore_Thread *thread;
Eina_List *sensors; Eina_List *sensors;
Eina_List *batteries; Eina_List *batteries;
@ -207,9 +208,8 @@ _win_del_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
Ui_Data *pd = data; Ui_Data *pd = data;
Ui *ui = pd->ui; Ui *ui = pd->ui;
ecore_thread_cancel(ui->sensors.thread); ecore_thread_cancel(pd->thread);
ecore_thread_wait(ui->sensors.thread, 0.5); ecore_thread_wait(pd->thread, 0.5);
ui->sensors.thread = NULL;
evas_object_del(obj); evas_object_del(obj);
ui->sensors.win = NULL; ui->sensors.win = NULL;
@ -341,8 +341,8 @@ ui_win_sensors_add(Ui *ui, Evas_Object *parent)
_sensors_refresh(pd); _sensors_refresh(pd);
ui->sensors.thread = ecore_thread_feedback_run(_sensors_update, pd->thread = ecore_thread_feedback_run(_sensors_update,
_sensors_update_feedback_cb, _sensors_update_feedback_cb,
NULL, NULL, pd, EINA_TRUE); NULL, NULL, pd, EINA_TRUE);
} }