netstar pushed a commit to branch master.

http://git.enlightenment.org/apps/evisum.git/commit/?id=8b46596a42a5b13c170c1c6ffb7a1e5b2156bbab

commit 8b46596a42a5b13c170c1c6ffb7a1e5b2156bbab
Author: Alastair Poole <nets...@gmail.com>
Date:   Sun May 16 12:36:36 2021 +0100

    ecore: use ecore timings.
    
    They should be accurate?
---
 src/bin/evisum_watcher.c | 28 +++++++++++++---------------
 1 file changed, 13 insertions(+), 15 deletions(-)

diff --git a/src/bin/evisum_watcher.c b/src/bin/evisum_watcher.c
index 87b85b0..88f3ce8 100644
--- a/src/bin/evisum_watcher.c
+++ b/src/bin/evisum_watcher.c
@@ -2,29 +2,27 @@
 #include <Ecore.h>
 #include "next/machine.h"
 
-static Eina_Thread *background_thread = NULL;
+static Ecore_Timer *background_timer;
 static Eina_List   *cores = NULL;
 static Eina_List   *batteries = NULL;
 static Eina_List   *sensors = NULL;
 static Eina_List   *network_interfaces = NULL;
 
-#define SECOND 1000000
-#define INTERVAL 16
-#define SLEEP_DURATION SECOND / INTERVAL
-#define CHECK_EVERY_SECOND(n) ((!n) || (!(n % INTERVAL))) 
-
 static void
-_cb_background_thread(void *data EINA_UNUSED, Ecore_Thread *thread)
+_cb_background_timer(void *data EINA_UNUSED)
 {
-   int64_t poll_count = 0;
+   static int64_t poll_count = 0;
+   static double t_prev = 0;
+   double t;
+
+   poll_count++;
+
+   t = ecore_loop_time_get();
 
-   while (!ecore_thread_check(thread))
-     {
-        if (CHECK_EVERY_SECOND(poll_count)) {}
+   if (t_prev) printf("%1.4f\n", t - t_prev);
+   t_prev = t; 
 
-        usleep(SLEEP_DURATION);
-       poll_count++;
-     }
+   return 1;
 }
 
 int
@@ -32,7 +30,7 @@ main(int argc, char **argv)
 {
    ecore_init();
 
-   background_thread = ecore_thread_run(_cb_background_thread, NULL, NULL, 
NULL);
+   background_timer = ecore_timer_add(0.025, _cb_background_timer, NULL);
 
    ecore_main_loop_begin();
 

-- 


Reply via email to