ecore_time_functions_example.c

Shows the difference between the three time functions. See the example explained.

//Compile with:
// gcc -o ecore_time_functions_example ecore_time_functions_example.c `pkg-config --libs --cflags ecore`
#include <Ecore.h>
#include <unistd.h>
static Eina_Bool
_timer_cb(void *data EINA_UNUSED)
{
printf("ecore time: %0.3f\n", ecore_time_get());
printf("loop time: %0.3f\n", ecore_loop_time_get());
printf("unix time: %0.3f\n", ecore_time_unix_get());
printf("\nSleep for 1 second...\n\n");
sleep(1);
printf("ecore time: %0.3f\n", ecore_time_get());
printf("loop time: %0.3f\n", ecore_loop_time_get());
printf("unix time: %0.3f\n", ecore_time_unix_get());
ecore_main_loop_quit();
return EINA_FALSE;
}
int
main(void)
{
if (!ecore_init())
{
printf("ERROR: Cannot init Ecore!\n");
return -1;
}
ecore_timer_add(0.1, _timer_cb, NULL);
ecore_main_loop_begin();
ecore_shutdown();
}
ecore_shutdown
EAPI int ecore_shutdown(void)
Shuts down connections, signal handlers sockets etc.
Definition: ecore.c:371
ecore_init
EAPI int ecore_init(void)
Sets up connections, signal handlers, sockets etc.
Definition: ecore.c:230
ecore_main_loop_quit
void ecore_main_loop_quit(void)
Quits the main loop once all the events currently on the queue have been processed.
Definition: ecore_main.c:1321
ecore_main_loop_begin
void ecore_main_loop_begin(void)
Runs the application main loop.
Definition: ecore_main.c:1311
ecore_time_unix_get
double ecore_time_unix_get(void)
Retrieves the current UNIX time as a floating point value in seconds.
Definition: ecore_time.c:61
ecore_time_get
double ecore_time_get(void)
Retrieves the current system time as a floating point value in seconds.
Definition: ecore_time.c:33
ecore_loop_time_get
double ecore_loop_time_get(void)
Retrieves the time at which the last loop stopped waiting for timeouts or events.
Definition: ecore_time.c:74
ecore_timer_add
Ecore_Timer * ecore_timer_add(double in, Ecore_Task_Cb func, const void *data)
Creates a timer to call the given function in the given period of time.
Definition: ecore_timer.c:189
EINA_FALSE
#define EINA_FALSE
boolean value FALSE (numerical value 0)
Definition: eina_types.h:533
Eina_Bool
unsigned char Eina_Bool
Type to mimic a boolean.
Definition: eina_types.h:527
EINA_UNUSED
#define EINA_UNUSED
Used to indicate that a function parameter is purposely unused.
Definition: eina_types.h:339