summaryrefslogtreecommitdiff
path: root/src/lib/ecore
diff options
context:
space:
mode:
authorCedric BAIL <cedric@osg.samsung.com>2017-06-02 16:27:02 -0700
committerCedric BAIL <cedric@osg.samsung.com>2017-06-02 16:28:28 -0700
commitbc13f96ae8b944fd3277a1d8ee86fc061842762a (patch)
treeeebc3a6fb6ea25362a4999e7e306bf934abea10e /src/lib/ecore
parent88fc88a305bc09c1b543b62556e66bdb8fa21d78 (diff)
ecore: simplify usage of poller by giving 3 class of event on the main loop object.
The internal logic should be improved further in the future to synchronize itself with loop wake up whenever possible (Especially true for the high frequency poller).
Diffstat (limited to 'src/lib/ecore')
-rw-r--r--src/lib/ecore/ecore_main.c75
-rw-r--r--src/lib/ecore/ecore_private.h10
-rw-r--r--src/lib/ecore/efl_loop.eo3
3 files changed, 86 insertions, 2 deletions
diff --git a/src/lib/ecore/ecore_main.c b/src/lib/ecore/ecore_main.c
index 6cf9e81068..868fc4ccf5 100644
--- a/src/lib/ecore/ecore_main.c
+++ b/src/lib/ecore/ecore_main.c
@@ -2869,6 +2869,14 @@ _efl_loop_efl_object_provider_find(Eo *obj, Efl_Loop_Data *pd, const Efl_Object
2869} 2869}
2870 2870
2871static void 2871static void
2872_poll_trigger(void *data, const Efl_Event *event)
2873{
2874 Eo *parent = efl_parent_get(event->object);
2875
2876 efl_event_callback_call(parent, data, NULL);
2877}
2878
2879static void
2872_check_event_catcher_add(void *data, const Efl_Event *event) 2880_check_event_catcher_add(void *data, const Efl_Event *event)
2873{ 2881{
2874 const Efl_Callback_Array_Item *array = event->info; 2882 const Efl_Callback_Array_Item *array = event->info;
@@ -2881,6 +2889,38 @@ _check_event_catcher_add(void *data, const Efl_Event *event)
2881 { 2889 {
2882 ++pd->idlers; 2890 ++pd->idlers;
2883 } 2891 }
2892 else if (array[i].desc == EFL_LOOP_EVENT_POLL_HIGH)
2893 {
2894 if (!pd->poll_high)
2895 {
2896 // Would be better to have it in sync with normal wake up
2897 // of the main loop for better energy efficiency, I guess.
2898 pd->poll_high = efl_add(EFL_LOOP_TIMER_CLASS, event->object,
2899 efl_event_callback_add(efl_added, EFL_LOOP_TIMER_EVENT_TICK, _poll_trigger, EFL_LOOP_EVENT_POLL_HIGH),
2900 efl_loop_timer_interval_set(efl_added, 1/60));
2901 }
2902 ++pd->pollers.high;
2903 }
2904 else if (array[i].desc == EFL_LOOP_EVENT_POLL_MEDIUM)
2905 {
2906 if (!pd->poll_medium)
2907 {
2908 pd->poll_medium = efl_add(EFL_LOOP_TIMER_CLASS, event->object,
2909 efl_event_callback_add(efl_added, EFL_LOOP_TIMER_EVENT_TICK, _poll_trigger, EFL_LOOP_EVENT_POLL_MEDIUM),
2910 efl_loop_timer_interval_set(efl_added, 6));
2911 }
2912 ++pd->pollers.medium;
2913 }
2914 else if (array[i].desc == EFL_LOOP_EVENT_POLL_LOW)
2915 {
2916 if (!pd->poll_low)
2917 {
2918 pd->poll_low = efl_add(EFL_LOOP_TIMER_CLASS, event->object,
2919 efl_event_callback_add(efl_added, EFL_LOOP_TIMER_EVENT_TICK, _poll_trigger, EFL_LOOP_EVENT_POLL_LOW),
2920 efl_loop_timer_interval_set(efl_added, 66));
2921 }
2922 ++pd->pollers.low;
2923 }
2884 } 2924 }
2885} 2925}
2886 2926
@@ -2897,6 +2937,33 @@ _check_event_catcher_del(void *data, const Efl_Event *event)
2897 { 2937 {
2898 --pd->idlers; 2938 --pd->idlers;
2899 } 2939 }
2940 else if (array[i].desc == EFL_LOOP_EVENT_POLL_HIGH)
2941 {
2942 --pd->pollers.high;
2943 if (!pd->pollers.high)
2944 {
2945 ecore_timer_del(pd->poll_high);
2946 pd->poll_high = NULL;
2947 }
2948 }
2949 else if (array[i].desc == EFL_LOOP_EVENT_POLL_MEDIUM)
2950 {
2951 --pd->pollers.medium;
2952 if (!pd->pollers.medium)
2953 {
2954 ecore_timer_del(pd->poll_medium);
2955 pd->poll_medium = NULL;
2956 }
2957 }
2958 else if (array[i].desc == EFL_LOOP_EVENT_POLL_LOW)
2959 {
2960 --pd->pollers.low;
2961 if (!pd->pollers.low)
2962 {
2963 ecore_timer_del(pd->poll_low);
2964 pd->poll_low = NULL;
2965 }
2966 }
2900 } 2967 }
2901} 2968}
2902 2969
@@ -2920,9 +2987,13 @@ _efl_loop_efl_object_constructor(Eo *obj, Efl_Loop_Data *pd)
2920EOLIAN static void 2987EOLIAN static void
2921_efl_loop_efl_object_destructor(Eo *obj, Efl_Loop_Data *pd) 2988_efl_loop_efl_object_destructor(Eo *obj, Efl_Loop_Data *pd)
2922{ 2989{
2923 efl_destructor(efl_super(obj, EFL_LOOP_CLASS));
2924
2925 eina_hash_free(pd->providers); 2990 eina_hash_free(pd->providers);
2991
2992 efl_del(pd->poll_low);
2993 efl_del(pd->poll_medium);
2994 efl_del(pd->poll_high);
2995
2996 efl_destructor(efl_super(obj, EFL_LOOP_CLASS));
2926} 2997}
2927 2998
2928typedef struct _Efl_Internal_Promise Efl_Internal_Promise; 2999typedef struct _Efl_Internal_Promise Efl_Internal_Promise;
diff --git a/src/lib/ecore/ecore_private.h b/src/lib/ecore/ecore_private.h
index 54daa5e30b..de6838b8b2 100644
--- a/src/lib/ecore/ecore_private.h
+++ b/src/lib/ecore/ecore_private.h
@@ -86,7 +86,17 @@ struct _Efl_Loop_Data
86{ 86{
87 Eina_Hash *providers; 87 Eina_Hash *providers;
88 88
89 Ecore_Timer *poll_high;
90 Ecore_Timer *poll_medium;
91 Ecore_Timer *poll_low;
92
89 int idlers; 93 int idlers;
94
95 struct {
96 int high;
97 int medium;
98 int low;
99 } pollers;
90}; 100};
91 101
92#define EVAS_FRAME_QUEUING 1 /* for test */ 102#define EVAS_FRAME_QUEUING 1 /* for test */
diff --git a/src/lib/ecore/efl_loop.eo b/src/lib/ecore/efl_loop.eo
index 0f00720623..aa8ae08d4c 100644
--- a/src/lib/ecore/efl_loop.eo
+++ b/src/lib/ecore/efl_loop.eo
@@ -106,6 +106,9 @@ class Efl.Loop (Efl.Object)
106 idle,exit @restart; [[Event occurs once the main loop exits the idle state.]] 106 idle,exit @restart; [[Event occurs once the main loop exits the idle state.]]
107 idle @restart; [[Event occurs once the main loop is idler. Be carefull, this will spin your CPU high if you keep listening on this event.]] 107 idle @restart; [[Event occurs once the main loop is idler. Be carefull, this will spin your CPU high if you keep listening on this event.]]
108 arguments: Efl.Loop.Arguments; [[Event happens when args are provided to the loop by args_add().]] 108 arguments: Efl.Loop.Arguments; [[Event happens when args are provided to the loop by args_add().]]
109 poll,high; [[Event occurs multiple time per second. The exact tick is undefined and could be adjusted system wide.]]
110 poll,medium; [[Event occurs multiple time per minute. The exact tick is undefined and could be adjusted system wide.]]
111 poll,low; [[Event occurs multiple time every 15 minutes. The exact tick is undefined and could be adjusted system wide.]]
109 } 112 }
110 implements { 113 implements {
111 Efl.Object.constructor; 114 Efl.Object.constructor;