2 @brief Ecore Library Public API Calls
4 These routines are used for Ecore Library interaction
14 Please see the @ref authors page for contact details.
16 @section intro Introduction
18 Ecore is a library of convenience functions. A brief explanation of how to use
19 it can be found in @ref Ecore_Main_Loop_Page.
21 The Ecore library provides the following modules:
22 @li @ref Ecore_File_Group
23 @li @ref Ecore_Con_Group
24 @li @link Ecore_Evas.h Ecore_Evas - Evas convenience functions. @endlink
25 @li @ref Ecore_FB_Group
26 @li @link Ecore_Ipc.h Ecore_IPC - Inter Process Communication functions. @endlink
27 @li @link Ecore_X.h Ecore_X - X Windows System wrapper. @endlink
28 @li @ref Ecore_Win32_Group
29 @li @ref Ecore_WinCE_Group
31 For more info on Ecore usage, there are these @ref Examples.
33 @section compiling How to compile using Ecore?
34 pkgconfig (.pc) files are installed for every ecore module.
35 Thus, to compile using any of them, you can use something like the following:
38 gcc *.c $(pkg-config ecore ecore-$x ecore-$y [...] --cflags --libs)
41 @section install How is it installed?
43 Suggested configure options for evas for a Linux desktop X display:
57 @author Carsten Haitzler <raster@rasterman.com>
58 @author Tom Gilbert <tom@linuxbrit.co.uk>
59 @author Burra <burra@colorado.edu>
60 @author Chris Ross <chris@darkrock.co.uk>
61 @author Term <term@twistedpath.org>
62 @author Tilman Sauerbeck <tilman@code-monkey.de>
63 @author Ibukun Olumuyiwa <ibukun@computer.org>
64 @author Yuri <da2001@hotmail.ru>
65 @author Nicholas Curran <quasar@bigblue.net.au>
66 @author Howell Tam <pigeon@pigeond.net>
67 @author Nathan Ingersoll <rbdpngn@users.sourceforge.net>
68 @author Andrew Elcock <andy@elcock.org>
69 @author Kim Woelders <kim@woelders.dk>
70 @author Sebastian Dransfeld <sebastid@tango.flipp.net>
71 @author Simon Poole <simon.armlinux@themalago.net>
72 @author Jorge Luis Zapata Muga <jorgeluis.zapata@gmail.com>
73 @author dan sinclair <zero@everburning.com>
74 @author Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de>
75 @author David 'onefang' Seikel <onefang@gmail.com>
76 @author Hisham 'CodeWarrior' Mardam Bey <hisham@hisham.cc>
77 @author Brian 'rephorm' Mattern <rephorm@rephorm.com>
78 @author Tim Horton <hortont424@gmail.com>
79 @author Arnaud de Turckheim 'quarium' <quarium@gmail.com>
80 @author Matt Barclay <mbarclay@gmail.com>
81 @author Peter Wehrfritz <peter.wehrfritz@web.de>
82 @author Albin "Lutin" Tonnerre <albin.tonnerre@gmail.com>
83 @author Vincent Torri <vincent.torri@gmail.com>
84 @author Lars Munch <lars@segv.dk>
85 @author Andre Dieb <andre.dieb@gmail.com>
86 @author Mathieu Taillefumier <mathieu.taillefumier@free.fr>
87 @author Rui Miguel Silva Seabra <rms@1407.org>
88 @author Samsung Electronics
90 @author Nicolas Aguirre <aguirre.nicolas@gmail.com>
91 @author Brett Nash <nash@nash.id.au>
92 @author Mike Blumenkrantz <mike@zentific.com>
93 @author Leif Middelschulte <leif.middelschulte@gmail.com>
94 @author Mike McCormack <mj.mccormack@samsung.com>
95 @author Sangho Park <gouache95@gmail.com>
96 @author Jihoon Kim <jihoon48.kim@samsung.com> <imfine98@gmail.com>
97 @author Daniel Juyung Seo <seojuyung2@gmail.com> <juyung.seo@samsung.com>
99 Please contact <enlightenment-devel@lists.sourceforge.net> to get in
100 contact with the developers and maintainers.
104 @page Ecore_Main_Loop_Page The Ecore Main Loop
106 @section intro What is Ecore?
108 Ecore is a clean and tiny event loop library with many modules to do lots of
109 convenient things for a programmer, to save time and effort.
111 It's small and lean, designed to work on embedded systems all the way to
112 large and powerful multi-cpu workstations. It serialises all system signals,
113 events etc. into a single event queue, that is easily processed without
114 needing to worry about concurrency. A properly written, event-driven program
115 using this kind of programming doesn't need threads, nor has to worry about
116 concurrency. It turns a program into a state machine, and makes it very
117 robust and easy to follow.
119 Ecore gives you other handy primitives, such as timers to tick over for you
120 and call specified functions at particular times so the programmer can use
121 this to do things, like animate, or time out on connections or tasks that take
124 Idle handlers are provided too, as well as calls on entering an idle state
125 (often a very good time to update the state of the program). All events that
126 enter the system are passed to specific callback functions that the program
127 sets up to handle those events. Handling them is simple and other Ecore
128 modules produce more events on the queue, coming from other sources such as
129 file descriptors etc.
131 Ecore also lets you have functions called when file descriptors become active
132 for reading or writing, allowing for streamlined, non-blocking IO.
134 Here is an example of a simple program and its basic event loop flow:
136 @image html prog_flow.png
137 @image latex prog_flow.eps width=\textwidth
141 @section work How does Ecore work?
143 Ecore is very easy to learn and use. All the function calls are designed to
144 be easy to remember, explicit in describing what they do, and heavily
145 name-spaced. Ecore programs can start and be very simple.
152 int main(int argc, const char **argv)
155 ecore_app_args_set(argc, argv);
156 ecore_main_loop_begin();
162 This program is very simple and does't check for errors, but it does start up
163 and begin a main loop waiting for events or timers to tick off. This program
164 doesn't set up any, but now we can expand on this simple program a little
165 more by adding some event handlers and timers.
170 Ecore_Timer *timer1 = NULL;
171 Ecore_Event_Handler *handler1 = NULL;
172 double start_time = 0.0;
174 int timer_func(void *data)
176 printf("Tick timer. Sec: %3.2f\n", ecore_time_get() - start_time);
180 int exit_func(void *data, int ev_type, void *ev)
182 Ecore_Event_Signal_Exit *e;
184 e = (Ecore_Event_Signal_Exit *)ev;
185 if (e->interrupt) printf("Exit: interrupt\n");
186 else if (e->quit) printf("Exit: quit\n");
187 else if (e->terminate) printf("Exit: terminate\n");
188 ecore_main_loop_quit();
192 int main(int argc, const char **argv)
195 ecore_app_args_set(argc, argv);
196 start_time = ecore_time_get();
197 handler1 = ecore_event_handler_add(ECORE_EVENT_SIGNAL_EXIT, exit_func, NULL);
198 timer1 = ecore_timer_add(0.5, timer_func, NULL);
199 ecore_main_loop_begin();
205 In the previous example, we initialize our application and get the time at
206 which our program has started so we can calculate an offset. We set
207 up a timer to tick off in 0.5 seconds, and since it returns 1, will
208 keep ticking off every 0.5 seconds until it returns 0, or is deleted
209 by hand. An event handler is set up to call a function - exit_func(),
210 whenever an event of type ECORE_EVENT_SIGNAL_EXIT is received (CTRL-C
211 on the command line will cause such an event to happen). If this event
212 occurs it tells you what kind of exit signal was received, and asks
213 the main loop to quit when it is finished by calling
214 ecore_main_loop_quit().
216 The handles returned by ecore_timer_add() and ecore_event_handler_add() are
217 only stored here as an example. If you don't need to address the timer or
218 event handler again you don't need to store the result, so just call the
219 function, and don't assign the result to any variable.
221 This program looks slightly more complex than needed to do these simple
222 things, but in principle, programs don't get any more complex. You add more
223 event handlers, for more events, will have more timers and such, BUT it all
224 follows the same principles as shown in this example.
229 @page Ecore_Config_Page The Enlightened Property Library
231 The Enlightened Property Library (Ecore_Config) is an adbstraction
232 from the complexities of writing your own configuration. It provides
233 many features using the Enlightenment 17 development libraries.
235 To use the library, you:
236 @li Set the default values of your properties.
237 @li Load the configuration from a file. You must set the default values
238 first, so that the library knows the correct type of each argument.
240 The following examples show how to use the Enlightened Property Library:
241 @li @link config_basic_example.c config_basic_example.c @endlink
242 @li @link config_listener_example.c config_listener_example.c @endlink
247 @page X_Window_System_Page X Window System
249 The Ecore library includes a wrapper for handling the X window system.
250 This page briefly explains what the X window system is and various terms
268 # ifdef EFL_ECORE_BUILD
270 # define EAPI __declspec(dllexport)
273 # endif /* ! DLL_EXPORT */
275 # define EAPI __declspec(dllimport)
276 # endif /* ! EFL_ECORE_BUILD */
280 # define EAPI __attribute__ ((visibility("default")))
287 #endif /* ! _WIN32 */
290 # include <winsock2.h>
291 #elif (defined (__FreeBSD__) && (__FreeBSD_version >= 420001)) || defined (__OpenBSD__)
292 # include <sys/select.h>
295 # include <sys/time.h>
299 #include <sys/types.h>
306 * @defgroup Ecore_Init_Group Ecore initialization and shutdown functions.
311 EAPI int ecore_init(void);
312 EAPI int ecore_shutdown(void);
320 * @defgroup Ecore_Main_Loop_Group Ecore main loop functions
322 * These are functions acting on Ecore's main loop itself or on
323 * events and infrastructure directly linked to it. This loop is
324 * designed to work on embedded systems all the way to large and
325 * powerful multi-cpu workstations.
327 * It serialises all system signals and events into a single event
328 * queue, that can be easily processed without needing to worry
329 * about concurrency. A properly written, event-driven program
330 * using this kind of programming does not need threads. It makes
331 * the program very robust and easy to follow.
333 * For example, for the main loop to be of any use, you need to be
334 * able to add @b events and event handlers on it. Events for file
335 * descriptor events are covered in @ref Ecore_FD_Handler_Group.
337 * Timer functions are covered in @ref Ecore_Time_Group.
339 * There is also provision for callbacks for when the loop enters or
340 * exits an @b idle state. See @ref Ecore_Idle_Group for more
343 * Functions are also provided for spawning child processes using
344 * @c fork(). See @ref Ecore_Exe_Group for more details on it.
346 * Here is an example of simple program and its basic event loop
349 * @image html prog_flow.png
350 * @image latex prog_flow.eps width=\textwidth
352 * For examples of setting up and using a main loop, see
353 * @ref Ecore_Main_Loop_Page.
358 #define ECORE_VERSION_MAJOR 1
359 #define ECORE_VERSION_MINOR 0
361 typedef struct _Ecore_Version
369 EAPI extern Ecore_Version *ecore_version;
371 #define ECORE_CALLBACK_CANCEL EINA_FALSE /**< Return value to remove a callback */
372 #define ECORE_CALLBACK_RENEW EINA_TRUE /**< Return value to keep a callback */
374 #define ECORE_CALLBACK_PASS_ON EINA_TRUE /**< Return value to pass event to next handler */
375 #define ECORE_CALLBACK_DONE EINA_FALSE /**< Return value to stop event handling */
378 * @typedef Ecore_Task_Cb Ecore_Task_Cb
379 * A callback run for a task (timer, idler, poller, animator, etc)
381 typedef Eina_Bool (*Ecore_Task_Cb) (void *data);
384 * @typedef Ecore_Eselect_Function Ecore_Eselect_Function
385 * A function which can be used to replace select() in the main loop
387 typedef int (*Ecore_Select_Function)(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout);
389 EAPI void ecore_main_loop_iterate(void);
391 EAPI void ecore_main_loop_select_func_set(Ecore_Select_Function func);
392 EAPI Ecore_Select_Function ecore_main_loop_select_func_get(void);
394 EAPI Eina_Bool ecore_main_loop_glib_integrate(void);
395 EAPI void ecore_main_loop_glib_always_integrate_disable(void);
397 EAPI void ecore_main_loop_begin(void);
398 EAPI void ecore_main_loop_quit(void);
401 * @typedef Ecore_Cb Ecore_Cb
402 * A generic callback called as a hook when a certain point in
403 * execution is reached.
405 typedef void (*Ecore_Cb) (void *data);
408 * @typedef Ecore_Data_Cb Ecore_Data_Cb
409 * A callback which is used to return data to the main function
411 typedef void *(*Ecore_Data_Cb) (void *data);
414 * @brief Call callback asynchronously in the main loop.
417 * @param callback The callback to call in the main loop
418 * @param data The data to give to that call back
420 * For all call that need to happen in the main loop (most EFL functions do),
421 * this helper function provide the infrastructure needed to do it safely
422 * by avoind dead lock, race condition and properly wake up the main loop.
424 * Remember after that function call, you should never touch again the @p data
425 * in the thread, it is owned by the main loop and you callback should take
426 * care of freeing it if necessary.
428 EAPI void ecore_main_loop_thread_safe_call_async(Ecore_Cb callback, void *data);
431 * @brief Call callback synchronously in the main loop.
434 * @param callback The callback to call in the main loop
435 * @param data The data to give to that call back
436 * @return the value returned by the callback in the main loop
438 * For all call that need to happen in the main loop (most EFL functions do),
439 * this helper function provide the infrastructure needed to do it safely
440 * by avoind dead lock, race condition and properly wake up the main loop.
442 * Remember this function will block until the callback is executed in the
443 * main loop. It can take time and you have no guaranty about the timeline.
445 EAPI void *ecore_main_loop_thread_safe_call_sync(Ecore_Data_Cb callback, void *data);
448 * @brief This function suspend the main loop in a know state
451 * @result EINA_TRUE if the main loop was suspended correcly.
453 * This function suspend the main loop in a know state, this let you
454 * use any EFL call you want after it return. Be carefull, the main loop
455 * is blocked until you call ecore_thread_main_loop_end(). This is
456 * the only sane way to achieve pseudo thread safety.
458 * Notice that until the main loop is blocked, the thread is blocked
459 * and their is noway around that.
461 * We still advise you, when possible, to use ecore_main_loop_thread_safe_call_async()
462 * as it will not block the thread nor the main loop.
464 EAPI Eina_Bool ecore_thread_main_loop_begin(void);
467 * @brief Unlock the main loop.
470 * After a call to ecore_thread_main_loop_begin(), you need to absolutly
471 * call ecore_thread_main_loop_end(), or you application will stay frozen.
473 EAPI void ecore_thread_main_loop_end(void);
480 * @defgroup Ecore_Event_Group Ecore Event functions
482 * Ecore events are used to wake up the Ecore main loop to warn
483 * about state changes, tasks completed, data available for reading
484 * or writing, etc. They are the base of the event oriented
487 * The idea is to write many functions (callbacks) that will be
488 * registered to specific events, and called when these events
489 * happen. This way, when the system state changes (a mouse click is
490 * detected, a key is pressed, or the content of a file changes, for
491 * example), the respective callbacks will be called with some
492 * information about that event. Usually the function/callback will
493 * have a data pointer to the event info (the position in the screen
494 * where the mouse was clicked, the name of the key that was
495 * pressed, or the name of the file that has changed).
497 * The basic usage, when one needs to watch for an existing event,
498 * is to register a callback to it using ecore_event_add(). Of
499 * course it's necessary to know beforehand what are the types of
500 * events that the system/library will emmit. This should be
501 * available with the documentation from that system/library.
503 * When writing a library or group of functions that need to inform
504 * about something, and you already are running on top of a main
505 * loop, it is usually a good approach to use events. This way you
506 * allow others to register as many callbacks as necessary to this
507 * event, and don't have to care about who is registering to it. The
508 * functions ecore_event_type_new() and ecore_event_add() are
509 * available for this purpose.
511 * Example that deals with events:
513 * @li @ref ecore_event_example_c
515 * @ingroup Ecore_Main_Loop_Group
520 #define ECORE_EVENT_NONE 0
521 #define ECORE_EVENT_SIGNAL_USER 1 /**< User signal event */
522 #define ECORE_EVENT_SIGNAL_HUP 2 /**< Hup signal event */
523 #define ECORE_EVENT_SIGNAL_EXIT 3 /**< Exit signal event */
524 #define ECORE_EVENT_SIGNAL_POWER 4 /**< Power signal event */
525 #define ECORE_EVENT_SIGNAL_REALTIME 5 /**< Realtime signal event */
526 #define ECORE_EVENT_COUNT 6
528 typedef struct _Ecore_Win32_Handler Ecore_Win32_Handler; /**< A handle for HANDLE handlers on Windows */
529 typedef struct _Ecore_Event_Handler Ecore_Event_Handler; /**< A handle for an event handler */
530 typedef struct _Ecore_Event_Filter Ecore_Event_Filter; /**< A handle for an event filter */
531 typedef struct _Ecore_Event Ecore_Event; /**< A handle for an event */
532 typedef struct _Ecore_Event_Signal_User Ecore_Event_Signal_User; /**< User signal event */
533 typedef struct _Ecore_Event_Signal_Hup Ecore_Event_Signal_Hup; /**< Hup signal event */
534 typedef struct _Ecore_Event_Signal_Exit Ecore_Event_Signal_Exit; /**< Exit signal event */
535 typedef struct _Ecore_Event_Signal_Power Ecore_Event_Signal_Power; /**< Power signal event */
536 typedef struct _Ecore_Event_Signal_Realtime Ecore_Event_Signal_Realtime; /**< Realtime signal event */
539 * @typedef Ecore_Filter_Cb
540 * A callback used for filtering events from the main loop.
542 typedef Eina_Bool (*Ecore_Filter_Cb) (void *data, void *loop_data, int type, void *event);
545 * @typedef Ecore_End_Cb Ecore_End_Cb
546 * This is the callback which is called at the end of a function,
547 * usually for cleanup purposes.
549 typedef void (*Ecore_End_Cb) (void *user_data, void *func_data);
552 * @typedef Ecore_Event_Handler_Cb Ecore_Event_Handler_Cb
553 * A callback used by the main loop to handle events of a specified
556 typedef Eina_Bool (*Ecore_Event_Handler_Cb) (void *data, int type, void *event);
558 struct _Ecore_Event_Signal_User /** User signal event */
560 int number; /**< The signal number. Either 1 or 2 */
561 void *ext_data; /**< Extension data - not used */
564 siginfo_t data; /**< Signal info */
568 struct _Ecore_Event_Signal_Hup /** Hup signal event */
570 void *ext_data; /**< Extension data - not used */
573 siginfo_t data; /**< Signal info */
577 struct _Ecore_Event_Signal_Exit /** Exit request event */
579 Eina_Bool interrupt : 1; /**< Set if the exit request was an interrupt signal*/
580 Eina_Bool quit : 1; /**< set if the exit request was a quit signal */
581 Eina_Bool terminate : 1; /**< Set if the exit request was a terminate singal */
582 void *ext_data; /**< Extension data - not used */
585 siginfo_t data; /**< Signal info */
589 struct _Ecore_Event_Signal_Power /** Power event */
591 void *ext_data; /**< Extension data - not used */
594 siginfo_t data; /**< Signal info */
598 struct _Ecore_Event_Signal_Realtime /** Realtime event */
600 int num; /**< The realtime signal's number */
603 siginfo_t data; /**< Signal info */
607 EAPI Ecore_Event_Handler *ecore_event_handler_add(int type, Ecore_Event_Handler_Cb func, const void *data);
608 EAPI void *ecore_event_handler_del(Ecore_Event_Handler *event_handler);
609 EAPI Ecore_Event *ecore_event_add(int type, void *ev, Ecore_End_Cb func_free, void *data);
610 EAPI void *ecore_event_del(Ecore_Event *event);
611 EAPI void *ecore_event_handler_data_get(Ecore_Event_Handler *eh);
612 EAPI void *ecore_event_handler_data_set(Ecore_Event_Handler *eh, const void *data);
613 EAPI int ecore_event_type_new(void);
614 EAPI Ecore_Event_Filter *ecore_event_filter_add(Ecore_Data_Cb func_start, Ecore_Filter_Cb func_filter, Ecore_End_Cb func_end, const void *data);
615 EAPI void *ecore_event_filter_del(Ecore_Event_Filter *ef);
616 EAPI int ecore_event_current_type_get(void);
617 EAPI void *ecore_event_current_event_get(void);
624 * @defgroup Ecore_Exe_Group Process Spawning Functions
626 * Functions that deal with and send signals to spawned processes.
628 * @ingroup Ecore_Main_Loop_Group
633 #define ECORE_EXE_PRIORITY_INHERIT 9999
635 EAPI extern int ECORE_EXE_EVENT_ADD; /**< A child process has been added */
636 EAPI extern int ECORE_EXE_EVENT_DEL; /**< A child process has been deleted (it exited, naming consistent with the rest of ecore). */
637 EAPI extern int ECORE_EXE_EVENT_DATA; /**< Data from a child process. */
638 EAPI extern int ECORE_EXE_EVENT_ERROR; /**< Errors from a child process. */
640 enum _Ecore_Exe_Flags /* flags for executing a child with its stdin and/or stdout piped back */
642 ECORE_EXE_NONE = 0, /**< No exe flags at all */
643 ECORE_EXE_PIPE_READ = 1, /**< Exe Pipe Read mask */
644 ECORE_EXE_PIPE_WRITE = 2, /**< Exe Pipe Write mask */
645 ECORE_EXE_PIPE_ERROR = 4, /**< Exe Pipe error mask */
646 ECORE_EXE_PIPE_READ_LINE_BUFFERED = 8, /**< Reads are buffered until a newline and delivered 1 event per line */
647 ECORE_EXE_PIPE_ERROR_LINE_BUFFERED = 16, /**< Errors are buffered until a newline and delivered 1 event per line */
648 ECORE_EXE_PIPE_AUTO = 32, /**< stdout and stderr are buffered automatically */
649 ECORE_EXE_RESPAWN = 64, /**< FIXME: Exe is restarted if it dies */
650 ECORE_EXE_USE_SH = 128, /**< Use /bin/sh to run the command. */
651 ECORE_EXE_NOT_LEADER = 256 /**< Do not use setsid() to have the executed process be its own session leader */
653 typedef enum _Ecore_Exe_Flags Ecore_Exe_Flags;
655 enum _Ecore_Exe_Win32_Priority
657 ECORE_EXE_WIN32_PRIORITY_IDLE, /**< Idle priority, for monitoring the system */
658 ECORE_EXE_WIN32_PRIORITY_BELOW_NORMAL, /**< Below default priority */
659 ECORE_EXE_WIN32_PRIORITY_NORMAL, /**< Default priority */
660 ECORE_EXE_WIN32_PRIORITY_ABOVE_NORMAL, /**< Above default priority */
661 ECORE_EXE_WIN32_PRIORITY_HIGH, /**< High priority, use with care as other threads in the system will not get processor time */
662 ECORE_EXE_WIN32_PRIORITY_REALTIME /**< Realtime priority, should be almost never used as it can interrupt system threads that manage mouse input, keyboard input, and background disk flushing */
664 typedef enum _Ecore_Exe_Win32_Priority Ecore_Exe_Win32_Priority;
666 typedef struct _Ecore_Exe Ecore_Exe; /**< A handle for spawned processes */
669 * @typedef Ecore_Exe_Cb Ecore_Exe_Cb
670 * A callback to run with the associated @ref Ecore_Exe, usually
671 * for cleanup purposes.
673 typedef void (*Ecore_Exe_Cb)(void *data, const Ecore_Exe *exe);
675 typedef struct _Ecore_Exe_Event_Add Ecore_Exe_Event_Add; /**< Spawned Exe add event */
676 typedef struct _Ecore_Exe_Event_Del Ecore_Exe_Event_Del; /**< Spawned Exe exit event */
677 typedef struct _Ecore_Exe_Event_Data_Line Ecore_Exe_Event_Data_Line; /**< Lines from a child process */
678 typedef struct _Ecore_Exe_Event_Data Ecore_Exe_Event_Data; /**< Data from a child process */
680 struct _Ecore_Exe_Event_Add /** Process add event */
682 Ecore_Exe *exe; /**< The handle to the added process */
683 void *ext_data; /**< Extension data - not used */
686 struct _Ecore_Exe_Event_Del /** Process exit event */
688 pid_t pid; /**< The process ID of the process that exited */
689 int exit_code; /**< The exit code of the process */
690 Ecore_Exe *exe; /**< The handle to the exited process, or NULL if not found */
691 int exit_signal; /** < The signal that caused the process to exit */
692 Eina_Bool exited : 1; /** < set to 1 if the process exited of its own accord */
693 Eina_Bool signalled : 1; /** < set to 1 id the process exited due to uncaught signal */
694 void *ext_data; /**< Extension data - not used */
696 siginfo_t data; /**< Signal info */
700 struct _Ecore_Exe_Event_Data_Line /**< Lines from a child process */
706 struct _Ecore_Exe_Event_Data /** Data from a child process event */
708 Ecore_Exe *exe; /**< The handle to the process */
709 void *data; /**< the raw binary data from the child process that was received */
710 int size; /**< the size of this data in bytes */
711 Ecore_Exe_Event_Data_Line *lines; /**< an array of line data if line buffered, the last one has it's line member set to NULL */
714 EAPI void ecore_exe_run_priority_set(int pri);
715 EAPI int ecore_exe_run_priority_get(void);
716 EAPI Ecore_Exe *ecore_exe_run(const char *exe_cmd, const void *data);
717 EAPI Ecore_Exe *ecore_exe_pipe_run(const char *exe_cmd, Ecore_Exe_Flags flags, const void *data);
718 EAPI void ecore_exe_callback_pre_free_set(Ecore_Exe *exe, Ecore_Exe_Cb func);
719 EAPI Eina_Bool ecore_exe_send(Ecore_Exe *exe, const void *data, int size);
720 EAPI void ecore_exe_close_stdin(Ecore_Exe *exe);
721 EAPI void ecore_exe_auto_limits_set(Ecore_Exe *exe, int start_bytes, int end_bytes, int start_lines, int end_lines);
722 EAPI Ecore_Exe_Event_Data *ecore_exe_event_data_get(Ecore_Exe *exe, Ecore_Exe_Flags flags);
723 EAPI void ecore_exe_event_data_free(Ecore_Exe_Event_Data *data);
724 EAPI void *ecore_exe_free(Ecore_Exe *exe);
725 EAPI pid_t ecore_exe_pid_get(const Ecore_Exe *exe);
726 EAPI void ecore_exe_tag_set(Ecore_Exe *exe, const char *tag);
727 EAPI const char *ecore_exe_tag_get(const Ecore_Exe *exe);
728 EAPI const char *ecore_exe_cmd_get(const Ecore_Exe *exe);
729 EAPI void *ecore_exe_data_get(const Ecore_Exe *exe);
730 EAPI void *ecore_exe_data_set(Ecore_Exe *exe, void *data);
731 EAPI Ecore_Exe_Flags ecore_exe_flags_get(const Ecore_Exe *exe);
732 EAPI void ecore_exe_pause(Ecore_Exe *exe);
733 EAPI void ecore_exe_continue(Ecore_Exe *exe);
734 EAPI void ecore_exe_interrupt(Ecore_Exe *exe);
735 EAPI void ecore_exe_quit(Ecore_Exe *exe);
736 EAPI void ecore_exe_terminate(Ecore_Exe *exe);
737 EAPI void ecore_exe_kill(Ecore_Exe *exe);
738 EAPI void ecore_exe_signal(Ecore_Exe *exe, int num);
739 EAPI void ecore_exe_hup(Ecore_Exe *exe);
746 * @defgroup Ecore_FD_Handler_Group File Event Handling Functions
748 * Functions that deal with file descriptor handlers.
750 * The @ref Ecore_Fd_Handler can be used to watch a file descriptor
751 * for data available for reading, for the availability to write
752 * without blocking, and for errors on the file descriptor.
754 * ecore_main_fd_handler_add() is used to setup a handler for a
755 * given file descriptor. This file descriptor can be the standard
756 * input, a network socket, a stream received through some driver
757 * of a hardware decoder, etc. Thus it can contain errors, like a
758 * disconnection, a broken pipe, and so, and that's why it's
759 * possible to check for these errors with the @ref ECORE_FD_ERROR
762 * An @ref Ecore_Fd_Handler can be used to watch on a file
763 * descriptor without blocking, still being able to receive events,
764 * expire timers, and other watch for other things that happen in
765 * the Ecore main loop.
767 * Example of use of a file descriptor handler:
768 * @li @ref ecore_fd_handler_example_c
770 * @ingroup Ecore_Main_Loop_Group
775 typedef struct _Ecore_Fd_Handler Ecore_Fd_Handler; /**< A handle for Fd handlers */
777 enum _Ecore_Fd_Handler_Flags
779 ECORE_FD_READ = 1, /**< Fd Read mask */
780 ECORE_FD_WRITE = 2, /**< Fd Write mask */
781 ECORE_FD_ERROR = 4 /**< Fd Error mask */
783 typedef enum _Ecore_Fd_Handler_Flags Ecore_Fd_Handler_Flags;
786 * @typedef Ecore_Fd_Cb Ecore_Fd_Cb
787 * A callback used by an @ref Ecore_Fd_Handler.
789 typedef Eina_Bool (*Ecore_Fd_Cb) (void *data, Ecore_Fd_Handler *fd_handler);
792 * @typedef Ecore_Fd_Prep_Cb Ecore_Fd_Prep_Cb
793 * A callback used by an @ref Ecore_Fd_Handler.
795 typedef void (*Ecore_Fd_Prep_Cb) (void *data, Ecore_Fd_Handler *fd_handler);
798 * @typedef Ecore_Win32_Handle_Cb Ecore_Win32_Handle_Cb
799 * A callback used by an @ref Ecore_Win32_Handler.
801 typedef Eina_Bool (*Ecore_Win32_Handle_Cb) (void *data, Ecore_Win32_Handler *wh);
803 EAPI Ecore_Fd_Handler *ecore_main_fd_handler_add(int fd, Ecore_Fd_Handler_Flags flags, Ecore_Fd_Cb func, const void *data,
804 Ecore_Fd_Cb buf_func, const void *buf_data);
805 EAPI void ecore_main_fd_handler_prepare_callback_set(Ecore_Fd_Handler *fd_handler, Ecore_Fd_Prep_Cb func, const void *data);
806 EAPI void *ecore_main_fd_handler_del(Ecore_Fd_Handler *fd_handler);
807 EAPI int ecore_main_fd_handler_fd_get(Ecore_Fd_Handler *fd_handler);
808 EAPI Eina_Bool ecore_main_fd_handler_active_get(Ecore_Fd_Handler *fd_handler, Ecore_Fd_Handler_Flags flags);
809 EAPI void ecore_main_fd_handler_active_set(Ecore_Fd_Handler *fd_handler, Ecore_Fd_Handler_Flags flags);
811 EAPI Ecore_Win32_Handler *ecore_main_win32_handler_add(void *h, Ecore_Win32_Handle_Cb func, const void *data);
812 EAPI void *ecore_main_win32_handler_del(Ecore_Win32_Handler *win32_handler);
819 * @defgroup Ecore_Poller_Group Ecore Poll functions
821 * These functions are for the need to poll information, but provide
822 * a shared abstracted API to pool such polling to minimise wakeup
823 * and ensure all the polling happens in as few spots as possible
824 * areound a core poll interval. For now only 1 core poller type is
825 * supprted: ECORE_POLLER_CORE
827 * Example of @ref Ecore_Poller:
828 * @li @ref ecore_poller_example_c
830 * @ingroup Ecore_Main_Loop_Group
835 enum _Ecore_Poller_Type /* Poller types */
837 ECORE_POLLER_CORE = 0 /**< The core poller interval */
839 typedef enum _Ecore_Poller_Type Ecore_Poller_Type;
841 typedef struct _Ecore_Poller Ecore_Poller; /**< A handle for pollers */
843 EAPI void ecore_poller_poll_interval_set(Ecore_Poller_Type type, double poll_time);
844 EAPI double ecore_poller_poll_interval_get(Ecore_Poller_Type type);
845 EAPI Eina_Bool ecore_poller_poller_interval_set(Ecore_Poller *poller, int interval);
846 EAPI int ecore_poller_poller_interval_get(Ecore_Poller *poller);
847 EAPI Ecore_Poller *ecore_poller_add(Ecore_Poller_Type type, int interval, Ecore_Task_Cb func, const void *data);
848 EAPI void *ecore_poller_del(Ecore_Poller *poller);
855 * @defgroup Ecore_Animator_Group Ecore Animator functions
857 * @brief Ecore animators are a helper to simplify creating
860 * Creating an animation is as simple as saying for how long it
861 * should be run and having a callback that does the animation,
862 * something like this:
865 * _do_animation(void *data, double pos)
867 * evas_object_move(data, 100 * pos, 100 * pos);
868 * ... do some more animating ...
871 * ecore_animator_timeline_add(2, _do_animation, my_evas_object);
873 * In the sample above we create an animation to move
874 * @c my_evas_object from position (0,0) to (100,100) in 2 seconds.
876 * If your animation will run for an unspecified amount of time you
877 * can use ecore_animator_add(), which is like using
878 * ecore_timer_add() with the interval being the
879 * @ref ecore_animator_frametime_set "framerate". Note that this has
880 * tangible benefits to creating a timer for each animation in terms
883 * For a more detailed example that show several animation see
884 * @ref tutorial_ecore_animator.
886 * @ingroup Ecore_Main_Loop_Group
891 typedef struct _Ecore_Animator Ecore_Animator; /**< A handle for animators */
893 enum _Ecore_Pos_Map /* Position mappings */
895 ECORE_POS_MAP_LINEAR, /**< Linear 0.0 -> 1.0 */
896 ECORE_POS_MAP_ACCELERATE, /**< Start slow then speed up */
897 ECORE_POS_MAP_DECELERATE, /**< Start fast then slow down */
898 ECORE_POS_MAP_SINUSOIDAL, /**< Start slow, speed up then slow down at end */
899 ECORE_POS_MAP_ACCELERATE_FACTOR, /**< Start slow then speed up, v1 being a power factor, 0.0 being linear, 1.0 being normal accelerate, 2.0 being much more pronounced accelerate (squared), 3.0 being cubed, etc. */
900 ECORE_POS_MAP_DECELERATE_FACTOR, /**< Start fast then slow down, v1 being a power factor, 0.0 being linear, 1.0 being normal decelerate, 2.0 being much more pronounced decelerate (squared), 3.0 being cubed, etc. */
901 ECORE_POS_MAP_SINUSOIDAL_FACTOR, /**< Start slow, speed up then slow down at end, v1 being a power factor, 0.0 being linear, 1.0 being normal sinusoidal, 2.0 being much more pronounced sinusoidal (squared), 3.0 being cubed, etc. */
902 ECORE_POS_MAP_DIVISOR_INTERP, /**< Start at gradient * v1, interpolated via power of v2 curve */
903 ECORE_POS_MAP_BOUNCE, /**< Start at 0.0 then "drop" like a ball bouncing to the ground at 1.0, and bounce v2 times, with decay factor of v1 */
904 ECORE_POS_MAP_SPRING /**< Start at 0.0 then "wobble" like a spring rest position 1.0, and wobble v2 times, with decay factor of v1 */
906 typedef enum _Ecore_Pos_Map Ecore_Pos_Map;
908 enum _Ecore_Animator_Source /* Timing sources for animators */
910 ECORE_ANIMATOR_SOURCE_TIMER, /**< The default system clock/timer based animator that ticks every "frametime" seconds */
911 ECORE_ANIMATOR_SOURCE_CUSTOM /**< A custom animator trigger that you need to call ecore_animator_trigger() to make it tick */
913 typedef enum _Ecore_Animator_Source Ecore_Animator_Source;
916 * @typedef Ecore_Timeline_Cb Ecore_Timeline_Cb
917 * A callback run for a task (animators with runtimes)
919 typedef Eina_Bool (*Ecore_Timeline_Cb) (void *data, double pos);
922 * @brief Add an animator to call @p func at every animaton tick during main
925 * @param func The function to call when it ticks off
926 * @param data The data to pass to the function
927 * @return A handle to the new animator
929 * This function adds a animator and returns its handle on success and NULL on
930 * failure. The function @p func will be called every N seconds where N is the
931 * @p frametime interval set by ecore_animator_frametime_set(). The function
932 * will be passed the @p data pointer as its parameter.
934 * When the animator @p func is called, it must return a value of either 1 or
935 * 0. If it returns 1 (or ECORE_CALLBACK_RENEW), it will be called again at
936 * the next tick, or if it returns 0 (or ECORE_CALLBACK_CANCEL) it will be
937 * deleted automatically making any references/handles for it invalid.
939 * @note The default @p frametime value is 1/30th of a second.
941 * @see ecore_animator_timeline_add()
942 * @see ecore_animator_frametime_set()
944 EAPI Ecore_Animator *ecore_animator_add(Ecore_Task_Cb func, const void *data);
946 * @brief Add a animator that runs for a limited time
948 * @param runtime The time to run in seconds
949 * @param func The function to call when it ticks off
950 * @param data The data to pass to the function
951 * @return A handle to the new animator
953 * This function is just like ecore_animator_add() except the animator only
954 * runs for a limited time specified in seconds by @p runtime. Once the
955 * runtime the animator has elapsed (animator finished) it will automatically
956 * be deleted. The callback function @p func can return ECORE_CALLBACK_RENEW
957 * to keep the animator running or ECORE_CALLBACK_CANCEL ro stop it and have
958 * it be deleted automatically at any time.
960 * The @p func will ALSO be passed a position parameter that will be in value
961 * from 0.0 to 1.0 to indicate where along the timeline (0.0 start, 1.0 end)
962 * the animator run is at. If the callback wishes not to have a linear
963 * transition it can "map" this value to one of several curves and mappings
964 * via ecore_animator_pos_map().
966 * @note The default @p frametime value is 1/30th of a second.
968 * @see ecore_animator_add()
969 * @see ecore_animator_pos_map()
972 EAPI Ecore_Animator *ecore_animator_timeline_add(double runtime, Ecore_Timeline_Cb func, const void *data);
974 * @brief Delete the specified animator from the animator list.
976 * @param animator The animator to delete
977 * @return The data pointer set for the animator on add
979 * Delete the specified @p animator from the set of animators that are
980 * executed during main loop execution. This function returns the data
981 * parameter that was being passed to the callback on success, or NULL on
982 * failure. After this call returns the specified animator object @p animator
983 * is invalid and should not be used again. It will not get called again after
986 EAPI void *ecore_animator_del(Ecore_Animator *animator);
988 * @brief Suspend the specified animator.
990 * @param animator The animator to delete
992 * The specified @p animator will be temporarly removed from the set of
993 * animators that are executed during main loop.
995 * @warning Freezing an animator doesn't freeze accounting of how long that
996 * animator has been running. Therefore if the animator was created with
997 * ecore_animator_timeline_add() the @p pos argument given to the callback
998 * will increase as if the animator hadn't been frozen and the animator may
999 * have it's execution halted if @p runtime elapsed.
1001 EAPI void ecore_animator_freeze(Ecore_Animator *animator);
1003 * @brief Restore execution of the specified animator.
1005 * @param animator The animator to delete
1007 * The specified @p animator will be put back in the set of animators that are
1008 * executed during main loop.
1010 EAPI void ecore_animator_thaw(Ecore_Animator *animator);
1012 * @brief Set the animator call interval in seconds.
1014 * @param frametime The time in seconds in between animator ticks.
1016 * This function sets the time interval (in seconds) between animator ticks.
1017 * At every tick the callback of every existing animator will be called.
1019 * @warning Too small a value may cause performance issues and too high a
1020 * value may cause your animation to seem "jerky".
1022 * @note The default @p frametime value is 1/30th of a second.
1024 EAPI void ecore_animator_frametime_set(double frametime);
1026 * @brief Get the animator call interval in seconds.
1028 * @return The time in second in between animator ticks.
1030 * This function retrieves the time in seconds between animator ticks.
1032 * @see ecore_animator_frametime_set()
1034 EAPI double ecore_animator_frametime_get(void);
1036 * @brief Maps an input position from 0.0 to 1.0 along a timeline to a
1037 * position in a different curve.
1039 * @param pos The input position to map
1040 * @param map The mapping to use
1041 * @param v1 A parameter use by the mapping (pass 0.0 if not used)
1042 * @param v2 A parameter use by the mapping (pass 0.0 if not used)
1043 * @return The mapped value
1045 * Takes an input position (0.0 to 1.0) and maps to a new position (normally
1046 * between 0.0 and 1.0, but it may go above/below 0.0 or 1.0 to show that it
1047 * has "overshot" the mark) using some interpolation (mapping) algorithm.
1049 * This function useful to create non-linear animations. It offers a variety
1050 * of possible animaton curves to be used:
1051 * @li ECORE_POS_MAP_LINEAR - Linear, returns @p pos
1052 * @li ECORE_POS_MAP_ACCELERATE - Start slow then speed up
1053 * @li ECORE_POS_MAP_DECELERATE - Start fast then slow down
1054 * @li ECORE_POS_MAP_SINUSOIDAL - Start slow, speed up then slow down at end
1055 * @li ECORE_POS_MAP_ACCELERATE_FACTOR - Start slow then speed up, v1 being a
1056 * power factor, 0.0 being linear, 1.0 being ECORE_POS_MAP_ACCELERATE, 2.0
1057 * being much more pronounced accelerate (squared), 3.0 being cubed, etc.
1058 * @li ECORE_POS_MAP_DECELERATE_FACTOR - Start fast then slow down, v1 being a
1059 * power factor, 0.0 being linear, 1.0 being ECORE_POS_MAP_DECELERATE, 2.0
1060 * being much more pronounced decelerate (squared), 3.0 being cubed, etc.
1061 * @li ECORE_POS_MAP_SINUSOIDAL_FACTOR - Start slow, speed up then slow down
1062 * at end, v1 being a power factor, 0.0 being linear, 1.0 being
1063 * ECORE_POS_MAP_SINUSOIDAL, 2.0 being much more pronounced sinusoidal
1064 * (squared), 3.0 being cubed, etc.
1065 * @li ECORE_POS_MAP_DIVISOR_INTERP - Start at gradient * v1, interpolated via
1067 * @li ECORE_POS_MAP_BOUNCE - Start at 0.0 then "drop" like a ball bouncing to
1068 * the ground at 1.0, and bounce v2 times, with decay factor of v1
1069 * @li ECORE_POS_MAP_SPRING - Start at 0.0 then "wobble" like a spring rest
1070 * position 1.0, and wobble v2 times, with decay factor of v1
1071 * @note When not listed v1 and v2 have no effect.
1073 * @image html ecore-pos-map.png
1074 * @image latex ecore-pos-map.eps width=\textwidth
1076 * One way to use this would be:
1078 * double pos; // input position in a timeline from 0.0 to 1.0
1079 * double out; // output position after mapping
1080 * int x1, y1, x2, y2; // x1 & y1 are start position, x2 & y2 are end position
1081 * int x, y; // x & y are the calculated position
1083 * out = ecore_animator_pos_map(pos, ECORE_POS_MAP_BOUNCE, 1.8, 7);
1084 * x = (x1 * out) + (x2 * (1.0 - out));
1085 * y = (y1 * out) + (y2 * (1.0 - out));
1086 * move_my_object_to(myobject, x, y);
1088 * This will make an animaton that bounces 7 each times diminishing by a
1091 * @see _Ecore_Pos_Map
1095 EAPI double ecore_animator_pos_map(double pos, Ecore_Pos_Map map, double v1, double v2);
1097 * @brief Set the source of animator ticks for the mainloop
1099 * @param source The source of animator ticks to use
1101 * This sets the source of animator ticks. When an animator is active the
1102 * mainloop will "tick" over frame by frame calling all animators that are
1103 * registered until none are. The mainloop will tick at a given rate based
1104 * on the animator source. The default source is the system clock timer
1105 * source - ECORE_ANIMATOR_SOURCE_TIMER. This source uses the system clock
1106 * to tick over every N seconds (specified by ecore_animator_frametime_set(),
1107 * with the default being 1/30th of a second unless set otherwise). You can
1108 * set a custom tick source by setting the source to
1109 * ECORE_ANIMATOR_SOURCE_CUSTOM and then drive it yourself based on some input
1110 * tick source (like another application via ipc, some vertical blanking
1111 * interrupt interrupt etc.) using
1112 * ecore_animator_custom_source_tick_begin_callback_set() and
1113 * ecore_animator_custom_source_tick_end_callback_set() to set the functions
1114 * that will be called to start and stop the ticking source, which when it
1115 * gets a "tick" should call ecore_animator_custom_tick() to make the "tick" over 1
1118 EAPI void ecore_animator_source_set(Ecore_Animator_Source source);
1120 * @brief Get the animator source currently set.
1122 * @return The current animator source
1124 * This gets the current animator source.
1126 * @see ecore_animator_source_set()
1128 EAPI Ecore_Animator_Source ecore_animator_source_get(void);
1130 * @brief Set the function that begins a custom animator tick source
1132 * @param func The function to call when ticking is to begin
1133 * @param data The data passed to the tick begin function as its parameter
1135 * The Ecore Animator infrastructure handles tracking if animators are needed
1136 * or not and which ones need to be called and when, but when the tick source
1137 * is custom, you have to provide a tick source by calling
1138 * ecore_animator_custom_tick() to indicate a frame tick happened. In order
1139 * to allow the source of ticks to be dynamically enabled or disabled as
1140 * needed, the @p func when set is called to enable the tick source to
1141 * produce tick events that call ecore_animator_custom_tick(). If @p func
1142 * is NULL then no function is called to begin custom ticking.
1144 * @see ecore_animator_source_set()
1145 * @see ecore_animator_custom_source_tick_end_callback_set()
1146 * @see ecore_animator_custom_tick()
1148 EAPI void ecore_animator_custom_source_tick_begin_callback_set(Ecore_Cb func, const void *data);
1150 * @brief Set the function that ends a custom animator tick source
1152 * @param func The function to call when ticking is to end
1153 * @param data The data passed to the tick end function as its parameter
1155 * This function is a matching pair to the function set by
1156 * ecore_animator_custom_source_tick_begin_callback_set() and is called
1157 * when ticking is to stop. If @p func is NULL then no function will be
1158 * called to stop ticking. For more information please see
1159 * ecore_animator_custom_source_tick_begin_callback_set().
1161 * @see ecore_animator_source_set()
1162 * @see ecore_animator_custom_source_tick_begin_callback_set()
1163 * @see ecore_animator_custom_tick()
1165 EAPI void ecore_animator_custom_source_tick_end_callback_set(Ecore_Cb func, const void *data);
1167 * @brief Trigger a custom animator tick
1169 * When animator source is set to ECORE_ANIMATOR_SOURCE_CUSTOM, then calling
1170 * this function triggers a run of all animators currently registered with
1171 * Ecore as this indicates a "frame tick" happened. This will do nothing if
1172 * the animator source(set by ecore_animator_source_set()) is not set to
1173 * ECORE_ANIMATOR_SOURCE_CUSTOM.
1175 * @see ecore_animator_source_set()
1176 * @see ecore_animator_custom_source_tick_begin_callback_set
1177 * @see ecore_animator_custom_source_tick_end_callback_set()()
1179 EAPI void ecore_animator_custom_tick(void);
1186 * @defgroup Ecore_Time_Group Ecore Time functions
1188 * Functions that deal with time. These functions include those
1189 * that simply retrieve it in a given format, and those that create
1190 * events based on it.
1192 * The timer allows callbacks to be called at specific intervals.
1194 * Examples with functions that deal with time:
1195 * @li @ref ecore_time_functions_example_c
1196 * @li @ref ecore_timer_example_c
1198 * @ingroup Ecore_Main_Loop_Group
1203 typedef struct _Ecore_Timer Ecore_Timer; /**< A handle for timers */
1205 EAPI double ecore_time_get(void);
1206 EAPI double ecore_time_unix_get(void);
1207 EAPI double ecore_loop_time_get(void);
1209 EAPI Ecore_Timer *ecore_timer_add(double in, Ecore_Task_Cb func, const void *data);
1210 EAPI Ecore_Timer *ecore_timer_loop_add(double in, Ecore_Task_Cb func, const void *data);
1211 EAPI void *ecore_timer_del(Ecore_Timer *timer);
1212 EAPI void ecore_timer_interval_set(Ecore_Timer *timer, double in);
1213 EAPI double ecore_timer_interval_get(Ecore_Timer *timer);
1214 EAPI void ecore_timer_freeze(Ecore_Timer *timer);
1215 EAPI void ecore_timer_thaw(Ecore_Timer *timer);
1216 EAPI void ecore_timer_delay(Ecore_Timer *timer, double add);
1217 EAPI double ecore_timer_pending_get(Ecore_Timer *timer);
1218 EAPI double ecore_timer_precision_get(void);
1219 EAPI void ecore_timer_precision_set(double precision);
1220 EAPI char *ecore_timer_dump(void);
1227 * @defgroup Ecore_Idle_Group Ecore Idle functions
1229 * Callbacks that are called when the program enters or exits an
1232 * The ecore main loop enters an idle state when it is waiting for
1233 * timers to time out, data to come in on a file descriptor or any
1234 * other event to occur. You can set callbacks to be called when
1235 * the main loop enters an idle state, during an idle state or just
1236 * after the program wakes up.
1238 * Enterer callbacks are good for updating your program's state, if
1239 * it has a state engine. Once all of the enterer handlers are
1240 * called, the program will enter a "sleeping" state.
1242 * Idler callbacks are called when the main loop has called all
1243 * enterer handlers. They are useful for interfaces that require
1244 * polling and timers would be too slow to use.
1246 * If no idler callbacks are specified, then the process literally
1247 * goes to sleep. Otherwise, the idler callbacks are called
1248 * continuously while the loop is "idle", using as much CPU as is
1249 * available to the process.
1251 * Exiter callbacks are called when the main loop wakes up from an
1254 * @note Idle state doesn't mean that the @b program is idle, but
1255 * that the <b>main loop</b> is idle. It doesn't have any timers,
1256 * events, fd handlers or anything else to process (which in most
1257 * <em>event driven</em> programs also means that the @b program is
1258 * idle too, but it's not a rule). The program itself may be doing
1259 * a lot of processing in the idler, or in another thread, for
1262 * Example with functions that deal with idle state:
1264 * @li @ref ecore_idler_example_c
1266 * @ingroup Ecore_Main_Loop_Group
1271 typedef struct _Ecore_Idler Ecore_Idler; /**< A handle for idlers */
1272 typedef struct _Ecore_Idle_Enterer Ecore_Idle_Enterer; /**< A handle for idle enterers */
1273 typedef struct _Ecore_Idle_Exiter Ecore_Idle_Exiter; /**< A handle for idle exiters */
1276 * Add an idler handler.
1277 * @param func The function to call when idling.
1278 * @param data The data to be passed to this @p func call.
1279 * @return A idler handle if successfully added. NULL otherwise.
1281 * Add an idler handle to the event loop, returning a handle on
1282 * success and NULL otherwise. The function @p func will be called
1283 * repeatedly while no other events are ready to be processed, as
1284 * long as it returns 1 (or ECORE_CALLBACK_RENEW). A return of 0
1285 * (or ECORE_CALLBACK_CANCEL) deletes the idler.
1287 * Idlers are useful for progressively prossessing data without blocking.
1289 EAPI Ecore_Idler *ecore_idler_add(Ecore_Task_Cb func, const void *data);
1292 * Delete an idler callback from the list to be executed.
1293 * @param idler The handle of the idler callback to delete
1294 * @return The data pointer passed to the idler callback on success. NULL
1297 EAPI void *ecore_idler_del(Ecore_Idler *idler);
1299 EAPI Ecore_Idle_Enterer *ecore_idle_enterer_add(Ecore_Task_Cb func, const void *data);
1300 EAPI Ecore_Idle_Enterer *ecore_idle_enterer_before_add(Ecore_Task_Cb func, const void *data);
1301 EAPI void *ecore_idle_enterer_del(Ecore_Idle_Enterer *idle_enterer);
1303 EAPI Ecore_Idle_Exiter *ecore_idle_exiter_add(Ecore_Task_Cb func, const void *data);
1304 EAPI void *ecore_idle_exiter_del(Ecore_Idle_Exiter *idle_exiter);
1311 * @defgroup Ecore_Thread_Group Ecore Thread functions
1313 * Facilities to run heavy tasks in different threads to avoid blocking
1316 * The EFL is, for the most part, not thread safe. This means that if you
1317 * have some task running in another thread and you have, for example, an
1318 * Evas object to show the status progress of this task, you cannot update
1319 * the object from within the thread. This can only be done from the main
1320 * thread, the one running the main loop. This problem can be solved
1321 * by running a thread that sends messages to the main one using an
1322 * @ref Ecore_Pipe_Group "Ecore_Pipe", but when you need to handle other
1323 * things like cancelling the thread, your code grows in coplexity and gets
1324 * much harder to maintain.
1326 * Ecore Thread is here to solve that problem. It is @b not a simple wrapper
1327 * around standard POSIX threads (or the equivalent in other systems) and
1328 * it's not meant to be used to run parallel tasks throughout the entire
1329 * duration of the program, especially when these tasks are performance
1330 * critical, as Ecore manages these tasks using a pool of threads based on
1331 * system configuration.
1333 * What Ecore Thread does, is make it a lot easier to dispatch a worker
1334 * function to perform some heavy task and then get the result once it
1335 * completes, without blocking the application's UI. In addition, cancelling
1336 * and rescheduling comes practically for free and the developer needs not
1337 * worry about how many threads are launched, since Ecore will schedule
1338 * them according to the number of processors the system has and maximum
1339 * amount of concurrent threads set for the application.
1341 * At the system level, Ecore will start a new thread on an as-needed basis
1342 * until the maximum set is reached. When no more threads can be launched,
1343 * new worker functions will be queued in a waiting list until a thread
1344 * becomes available. This way, system threads will be shared throughout
1345 * different worker functions, but running only one at a time. At the same
1346 * time, a worker function that is rescheduled may be run on a different
1347 * thread the next time.
1349 * The ::Ecore_Thread handler has two meanings, depending on what context
1350 * it is on. The one returned when starting a worker with any of the
1351 * functions ecore_thread_run() or ecore_thread_feedback_run() is an
1352 * identifier of that specific instance of the function and can be used from
1353 * the main loop with the ecore_thread_cancel() and ecore_thread_check()
1354 * functions. This handler must not be shared with the worker function
1355 * function running in the thread. This same handler will be the one received
1356 * on the @c end, @c cancel and @c feedback callbacks.
1358 * The worker function, that's the one running in the thread, also receives
1359 * an ::Ecore_Thread handler that can be used with ecore_thread_cancel() and
1360 * ecore_thread_check(), sharing the flag with the main loop. But this
1361 * handler is also associated with the thread where the function is running.
1362 * This has strong implications when working with thread local data.
1364 * There are two kinds of worker threads Ecore handles: simple, or short,
1365 * workers and feedback workers.
1367 * The first kind is for simple functions that perform a
1368 * usually small but time consuming task. Ecore will run this function in
1369 * a thread as soon as one becomes available and notify the calling user of
1370 * its completion once the task is done.
1372 * The following image shows the flow of a program running four tasks on
1373 * a pool of two threads.
1375 * @image html ecore_thread.png
1376 * @image rtf ecore_thread.png
1377 * @image latex ecore_thread.eps width=\textwidth
1379 * For larger tasks that may require continuous communication with the main
1380 * program, the feedback workers provide the same functionality plus a way
1381 * for the function running in the thread to send messages to the main
1384 * The next diagram omits some details shown in the previous one regarding
1385 * how threads are spawned and tasks are queued, but illustrates how feedback
1386 * jobs communicate with the main loop and the special case of threads
1387 * running out of pool.
1389 * @image html ecore_thread_feedback.png
1390 * @image rtf ecore_thread_feedback.png
1391 * @image latex ecore_thread_feedback.eps width=\textwidth
1393 * See an overview example in @ref ecore_thread_example_c.
1395 * @ingroup Ecore_Main_Loop_Group
1400 typedef struct _Ecore_Thread Ecore_Thread; /**< A handle for threaded jobs */
1403 * @typedef Ecore_Thread_Cb Ecore_Thread_Cb
1404 * A callback used by Ecore_Thread helper.
1406 typedef void (*Ecore_Thread_Cb) (void *data, Ecore_Thread *thread);
1408 * @typedef Ecore_Thread_Notify_Cb Ecore_Thread_Notify_Cb
1409 * A callback used by the main loop to receive data sent by an
1410 * @ref Ecore_Thread_Group.
1412 typedef void (*Ecore_Thread_Notify_Cb) (void *data, Ecore_Thread *thread, void *msg_data);
1415 * Schedule a task to run in a parallel thread to avoid locking the main loop
1417 * @param func_blocking The function that should run in another thread.
1418 * @param func_end Function to call from main loop when @p func_blocking
1419 * completes its task successfully (may be NULL)
1420 * @param func_cancel Function to call from main loop if the thread running
1421 * @p func_blocking is cancelled or fails to start (may be NULL)
1422 * @param data User context data to pass to all callbacks.
1423 * @return A new thread handler, or NULL on failure
1425 * This function will try to create a new thread to run @p func_blocking in,
1426 * or if the maximum number of concurrent threads has been reached, will
1427 * add it to the pending list, where it will wait until a thread becomes
1428 * available. The return value will be an ::Ecore_Thread handle that can
1429 * be used to cancel the thread before its completion.
1431 * @note This function should always return immediately, but in the rare
1432 * case that Ecore is built with no thread support, @p func_blocking will
1433 * be called here, actually blocking the main loop.
1435 * Once a thread becomes available, @p func_blocking will be run in it until
1436 * it finishes, then @p func_end is called from the thread containing the
1437 * main loop to inform the user of its completion. While in @p func_blocking,
1438 * no functions from the EFL can be used, except for those from Eina that are
1439 * marked to be thread-safe. Even for the latter, caution needs to be taken
1440 * if the data is shared across several threads.
1442 * @p func_end will be called from the main thread when @p func_blocking ends,
1443 * so here it's safe to use anything from the EFL freely.
1445 * The thread can also be cancelled before its completion calling
1446 * ecore_thread_cancel(), either from the main thread or @p func_blocking.
1447 * In this case, @p func_cancel will be called, also from the main thread
1448 * to inform of this happening. If the thread could not be created, this
1449 * function will be called and it's @c thread parameter will be NULL. It's
1450 * also safe to call any EFL function here, as it will be running in the
1453 * Inside @p func_blocking, it's possible to call ecore_thread_reschedule()
1454 * to tell Ecore that this function should be called again.
1456 * Be aware that no assumptions can be made about the order in which the
1457 * @p func_end callbacks for each task will be called. Once the function is
1458 * running in a different thread, it's the OS that will handle its running
1459 * schedule, and different functions may take longer to finish than others.
1460 * Also remember that just starting several tasks together doesn't mean they
1461 * will be running at the same time. Ecore will schedule them based on the
1462 * number of threads available for the particular system it's running in,
1463 * so some of the jobs started may be waiting until another one finishes
1464 * before it can execute its own @p func_blocking.
1466 * @see ecore_thread_feedback_run()
1467 * @see ecore_thread_cancel()
1468 * @see ecore_thread_reschedule()
1469 * @see ecore_thread_max_set()
1471 EAPI Ecore_Thread *ecore_thread_run(Ecore_Thread_Cb func_blocking,
1472 Ecore_Thread_Cb func_end,
1473 Ecore_Thread_Cb func_cancel,
1476 * Launch a thread to run a task than can talk back to the main thread
1478 * @param func_heavy The function that should run in another thread.
1479 * @param func_notify Function that receives the data sent from the thread
1480 * @param func_end Function to call from main loop when @p func_heavy
1481 * completes its task successfully
1482 * @param func_cancel Function to call from main loop if the thread running
1483 * @p func_heavy is cancelled or fails to start
1484 * @param data User context data to pass to all callback.
1485 * @param try_no_queue If you want to run outside of the thread pool.
1486 * @return A new thread handler, or NULL on failure
1488 * See ecore_thread_run() for a general description of this function.
1490 * The difference with the above is that ecore_thread_run() is meant for
1491 * tasks that don't need to communicate anything until they finish, while
1492 * this function is provided with a new callback, @p func_notify, that will
1493 * be called from the main thread for every message sent from @p func_heavy
1494 * with ecore_thread_feedback().
1496 * Like with ecore_thread_run(), a new thread will be launched to run
1497 * @p func_heavy unless the maximum number of simultaneous threadas has been
1498 * reached, in which case the function will be scheduled to run whenever a
1499 * running task ends and a thread becomes free. But if @p try_no_queue is
1500 * set, Ecore will first try to launch a thread outside of the pool to run
1501 * the task. If it fails, it will revert to the normal behaviour of using a
1502 * thread from the pool as if @p try_no_queue had not been set.
1504 * Keep in mind that Ecore handles the thread pool based on the number of
1505 * CPUs available, but running a thread outside of the pool doesn't count for
1506 * this, so having too many of them may have drastic effects over the
1507 * program's performance.
1509 * @see ecore_thread_feedback()
1510 * @see ecore_thread_run()
1511 * @see ecore_thread_cancel()
1512 * @see ecore_thread_reschedule()
1513 * @see ecore_thread_max_set()
1515 EAPI Ecore_Thread *ecore_thread_feedback_run(Ecore_Thread_Cb func_heavy,
1516 Ecore_Thread_Notify_Cb func_notify,
1517 Ecore_Thread_Cb func_end,
1518 Ecore_Thread_Cb func_cancel,
1520 Eina_Bool try_no_queue);
1522 * Cancel a running thread.
1524 * @param thread The thread to cancel.
1525 * @return Will return EINA_TRUE if the thread has been cancelled,
1526 * EINA_FALSE if it is pending.
1528 * This function can be called both in the main loop or in the running thread.
1530 * This function cancels a running thread. If @p thread can be immediately
1531 * cancelled (it's still pending execution after creation or rescheduling),
1532 * then the @c cancel callback will be called, @p thread will be freed and
1533 * the function will return EINA_TRUE.
1535 * If the thread is already running, then this function returns EINA_FALSE
1536 * after marking the @p thread as pending cancellation. For the thread to
1537 * actually be terminated, it needs to return from the user function back
1538 * into Ecore control. This can happen in several ways:
1539 * @li The function ends and returns normally. If it hadn't been cancelled,
1540 * @c func_end would be called here, but instead @c func_cancel will happen.
1541 * @li The function returns after requesting to be rescheduled with
1542 * ecore_thread_reschedule().
1543 * @li The function is prepared to leave early by checking if
1544 * ecore_thread_check() returns EINA_TRUE.
1546 * The user function can cancel itself by calling ecore_thread_cancel(), but
1547 * it should always use the ::Ecore_Thread handle passed to it and never
1548 * share it with the main loop thread by means of shared user data or any
1551 * @p thread will be freed and should not be used again if this function
1552 * returns EINA_TRUE or after the @c func_cancel callback returns.
1554 * @see ecore_thread_check()
1556 EAPI Eina_Bool ecore_thread_cancel(Ecore_Thread *thread);
1558 * Checks if a thread is pending cancellation
1560 * @param thread The thread to test.
1561 * @return EINA_TRUE if the thread is pending cancellation,
1562 * EINA_FALSE if it is not.
1564 * This function can be called both in the main loop or in the running thread.
1566 * When ecore_thread_cancel() is called on an already running task, the
1567 * thread is marked as pending cancellation. This function returns EINA_TRUE
1568 * if this mark is set for the given @p thread and can be used from the
1569 * main loop thread to check if a still active thread has been cancelled,
1570 * or from the user function running in the thread to check if it should
1571 * stop doing what it's doing and return early, effectively cancelling the
1574 * @see ecore_thread_cancel()
1576 EAPI Eina_Bool ecore_thread_check(Ecore_Thread *thread);
1578 * Sends data from the worker thread to the main loop
1580 * @param thread The current ::Ecore_Thread context to send data from
1581 * @param msg_data Data to be transmitted to the main loop
1582 * @return EINA_TRUE if @p msg_data was successfully sent to main loop,
1583 * EINA_FALSE if anything goes wrong.
1585 * You should use this function only in the @c func_heavy call.
1587 * Only the address to @p msg_data will be sent and once this function
1588 * returns EINA_TRUE, the job running in the thread should never touch the
1589 * contents of it again. The data sent should be malloc()'ed or something
1590 * similar, as long as it's not memory local to the thread that risks being
1591 * overwritten or deleted once it goes out of scope or the thread finishes.
1593 * Care must be taken that @p msg_data is properly freed in the @c func_notify
1594 * callback set when creating the thread.
1596 * @see ecore_thread_feedback_run()
1598 EAPI Eina_Bool ecore_thread_feedback(Ecore_Thread *thread, const void *msg_data);
1600 * Asks for the function in the thread to be called again at a later time
1602 * @param thread The current ::Ecore_Thread context to rescheduled
1603 * @return EINA_TRUE if the task was successfully rescheduled,
1604 * EINA_FALSE if anything goes wrong.
1606 * This function should be called only from the same function represented
1609 * Calling this function will mark the thread for a reschedule, so as soon
1610 * as it returns, it will be added to the end of the list of pending tasks.
1611 * If no other tasks are waiting or there are sufficient threads available,
1612 * the rescheduled task will be launched again immediately.
1614 * This should never return EINA_FALSE, unless it was called from the wrong
1615 * thread or with the wrong arguments.
1617 * The @c func_end callback set when the thread is created will not be
1618 * called until the function in the thread returns without being rescheduled.
1619 * Similarly, if the @p thread is cancelled, the reschedule will not take
1622 EAPI Eina_Bool ecore_thread_reschedule(Ecore_Thread *thread);
1624 * Gets the number of active threads running jobs
1626 * @return Number of active threads running jobs
1628 * This returns the number of threads currently running jobs of any type
1629 * through the Ecore_Thread API.
1631 * @note Jobs started through the ecore_thread_feedback_run() function with
1632 * the @c try_no_queue parameter set to EINA_TRUE will not be accounted for
1633 * in the return of this function unless the thread creation fails and it
1634 * falls back to using one from the pool.
1636 EAPI int ecore_thread_active_get(void);
1638 * Gets the number of short jobs waiting for a thread to run
1640 * @return Number of pending threads running "short" jobs
1642 * This returns the number of tasks started with ecore_thread_run() that are
1643 * pending, waiting for a thread to become available to run them.
1645 EAPI int ecore_thread_pending_get(void);
1647 * Gets the number of feedback jobs waiting for a thread to run
1649 * @return Number of pending threads running "feedback" jobs
1651 * This returns the number of tasks started with ecore_thread_feedback_run()
1652 * that are pending, waiting for a thread to become available to run them.
1654 EAPI int ecore_thread_pending_feedback_get(void);
1656 * Gets the total number of pending jobs
1658 * @return Number of pending threads running jobs
1660 * Same as the sum of ecore_thread_pending_get() and
1661 * ecore_thread_pending_feedback_get().
1663 EAPI int ecore_thread_pending_total_get(void);
1665 * Gets the maximum number of threads that can run simultaneously
1667 * @return Max possible number of Ecore_Thread's running concurrently
1669 * This returns the maximum number of Ecore_Thread's that may be running at
1670 * the same time. If this number is reached, new jobs started by either
1671 * ecore_thread_run() or ecore_thread_feedback_run() will be added to the
1672 * respective pending queue until one of the running threads finishes its
1673 * task and becomes available to run a new one.
1675 * By default, this will be the number of available CPUs for the
1676 * running program (as returned by eina_cpu_count()), or 1 if this value
1677 * could not be fetched.
1679 * @see ecore_thread_max_set()
1680 * @see ecore_thread_max_reset()
1682 EAPI int ecore_thread_max_get(void);
1684 * Sets the maximum number of threads allowed to run simultaneously
1686 * @param num The new maximum
1688 * This sets a new value for the maximum number of concurrently running
1689 * Ecore_Thread's. It @b must an integer between 1 and (2 * @c x), where @c x
1690 * is the number for CPUs available.
1692 * @see ecore_thread_max_get()
1693 * @see ecore_thread_max_reset()
1695 EAPI void ecore_thread_max_set(int num);
1697 * Resets the maximum number of concurrently running threads to the default
1699 * This resets the value returned by ecore_thread_max_get() back to its
1702 * @see ecore_thread_max_get()
1703 * @see ecore_thread_max_set()
1705 EAPI void ecore_thread_max_reset(void);
1707 * Gets the number of threads available for running tasks
1709 * @return The number of available threads
1711 * Same as doing ecore_thread_max_get() - ecore_thread_active_get().
1713 * This function may return a negative number only in the case the user
1714 * changed the maximum number of running threads while other tasks are
1717 EAPI int ecore_thread_available_get(void);
1719 * Adds some data to a hash local to the thread
1721 * @param thread The thread context the data belongs to
1722 * @param key The name under which the data will be stored
1723 * @param value The data to add
1724 * @param cb Function to free the data when removed from the hash
1725 * @param direct If true, this will not copy the key string (like
1726 * eina_hash_direct_add())
1727 * @return EINA_TRUE on success, EINA_FALSE on failure
1729 * Ecore Thread has a mechanism to share data across several worker functions
1730 * that run on the same system thread. That is, the data is stored per
1731 * thread and for a worker function to have access to it, it must be run
1732 * by the same thread that stored the data.
1734 * When there are no more workers pending, the thread will be destroyed
1735 * along with the internal hash and any data left in it will be freed with
1736 * the @p cb function given.
1738 * This set of functions is useful to share things around several instances
1739 * of a function when that thing is costly to create and can be reused, but
1740 * may only be used by one function at a time.
1742 * For example, if you have a program doing requisitions to a database,
1743 * these requisitions can be done in threads so that waiting for the
1744 * database to respond doesn't block the UI. Each of these threads will
1745 * run a function, and each function will be dependent on a connection to
1746 * the database, which may not be able to handle more than one request at
1747 * a time so for each running function you will need one connection handle.
1748 * The options then are:
1749 * @li Each function opens a connection when it's called, does the work and
1750 * closes the connection when it finishes. This may be costly, wasting a lot
1751 * of time on resolving hostnames, negotiating permissions and allocating
1753 * @li Open the connections in the main loop and pass it to the threads
1754 * using the data pointer. Even worse, it's just as costly as before and now
1755 * it may even be kept with connections open doing nothing until a thread
1756 * becomes available to run the function.
1757 * @li Have a way to share connection handles, so that each instance of the
1758 * function can check if an available connection exists, and if it doesn't,
1759 * create one and add it to the pool. When no more connections are needed,
1760 * they are all closed.
1762 * The last option is the most efficient, but it requires a lot of work to
1763 * implement properly. Using thread local data helps to achieve the same
1764 * result while avoiding doing all the tracking work on your code. The way
1765 * to use it would be, at the worker function, to ask for the connection
1766 * with ecore_thread_local_data_find() and if it doesn't exist, then open
1767 * a new one and save it with ecore_thread_local_data_add(). Do the work and
1768 * forget about the connection handle, when everything is done the function
1769 * just ends. The next worker to run on that thread will check if a
1770 * connection exists and find that it does, so the process of opening a
1771 * new one has been spared. When no more workers exist, the thread is
1772 * destroyed and the callback used when saving the connection will be called
1775 * This function adds the data @p value to the thread data under the given
1777 * No other value in the hash may have the same @p key. If you need to
1778 * change the value under a @p key, or you don't know if one exists already,
1779 * you can use ecore_thread_local_data_set().
1781 * Neither @p key nor @p value may be NULL and @p key will be copied in the
1782 * hash, unless @p direct is set, in which case the string used should not
1783 * be freed until the data is removed from the hash.
1785 * The @p cb function will be called when the data in the hash needs to be
1786 * freed, be it because it got deleted with ecore_thread_local_data_del() or
1787 * because @p thread was terminated and the hash destroyed. This parameter
1788 * may be NULL, in which case @p value needs to be manually freed after
1789 * removing it from the hash with either ecore_thread_local_data_del() or
1790 * ecore_thread_local_data_set(), but it's very unlikely that this is what
1793 * This function, and all of the others in the @c ecore_thread_local_data
1794 * family of functions, can only be called within the worker function running
1795 * in the thread. Do not call them from the main loop or from a thread
1796 * other than the one represented by @p thread.
1798 * @see ecore_thread_local_data_set()
1799 * @see ecore_thread_local_data_find()
1800 * @see ecore_thread_local_data_del()
1802 EAPI Eina_Bool ecore_thread_local_data_add(Ecore_Thread *thread, const char *key, void *value, Eina_Free_Cb cb, Eina_Bool direct);
1804 * Sets some data in the hash local to the given thread
1806 * @param thread The thread context the data belongs to
1807 * @param key The name under which the data will be stored
1808 * @param value The data to add
1809 * @param cb Function to free the data when removed from the hash
1811 * If no data exists in the hash under the @p key, this function adds
1812 * @p value in the hash under the given @p key and returns NULL.
1813 * The key itself is copied.
1815 * If the hash already contains something under @p key, the data will be
1816 * replaced by @p value and the old value will be returned.
1818 * NULL will also be returned if either @p key or @p value are NULL, or if
1819 * an error occurred.
1821 * This function, and all of the others in the @c ecore_thread_local_data
1822 * family of functions, can only be called within the worker function running
1823 * in the thread. Do not call them from the main loop or from a thread
1824 * other than the one represented by @p thread.
1826 * @see ecore_thread_local_data_add()
1827 * @see ecore_thread_local_data_del()
1828 * @see ecore_thread_local_data_find()
1830 EAPI void *ecore_thread_local_data_set(Ecore_Thread *thread, const char *key, void *value, Eina_Free_Cb cb);
1832 * Gets data stored in the hash local to the given thread
1834 * @param thread The thread context the data belongs to
1835 * @param key The name under which the data is stored
1836 * @return The value under the given key, or NULL on error
1838 * Finds and return the data stored in the shared hash under the key @p key.
1840 * This function, and all of the others in the @c ecore_thread_local_data
1841 * family of functions, can only be called within the worker function running
1842 * in the thread. Do not call them from the main loop or from a thread
1843 * other than the one represented by @p thread.
1845 * @see ecore_thread_local_data_add()
1846 * @see ecore_thread_local_data_wait()
1848 EAPI void *ecore_thread_local_data_find(Ecore_Thread *thread, const char *key);
1850 * Deletes from the thread's hash the data corresponding to the given key
1852 * @param thread The thread context the data belongs to
1853 * @param key The name under which the data is stored
1854 * @return EINA_TRUE on success, EINA_FALSE on failure
1856 * If there's any data stored associated with @p key in the global hash,
1857 * this function will remove it from it and return EINA_TRUE. If no data
1858 * exists or an error occurs, it returns EINA_FALSE.
1860 * If the data was added to the hash with a free function, then it will
1861 * also be freed after removing it from the hash, otherwise it requires
1862 * to be manually freed by the user, which means that if no other reference
1863 * to it exists before calling this function, it will result in a memory
1866 * This function, and all of the others in the @c ecore_thread_local_data
1867 * family of functions, can only be called within the worker function running
1868 * in the thread. Do not call them from the main loop or from a thread
1869 * other than the one represented by @p thread.
1871 * @see ecore_thread_local_data_add()
1873 EAPI Eina_Bool ecore_thread_local_data_del(Ecore_Thread *thread, const char *key);
1876 * Adds some data to a hash shared by all threads
1878 * @param key The name under which the data will be stored
1879 * @param value The data to add
1880 * @param cb Function to free the data when removed from the hash
1881 * @param direct If true, this will not copy the key string (like
1882 * eina_hash_direct_add())
1883 * @return EINA_TRUE on success, EINA_FALSE on failure
1885 * Ecore Thread keeps a hash that can be used to share data across several
1886 * threads, including the main loop one, without having to manually handle
1887 * mutexes to do so safely.
1889 * This function adds the data @p value to this hash under the given @p key.
1890 * No other value in the hash may have the same @p key. If you need to
1891 * change the value under a @p key, or you don't know if one exists already,
1892 * you can use ecore_thread_global_data_set().
1894 * Neither @p key nor @p value may be NULL and @p key will be copied in the
1895 * hash, unless @p direct is set, in which case the string used should not
1896 * be freed until the data is removed from the hash.
1898 * The @p cb function will be called when the data in the hash needs to be
1899 * freed, be it because it got deleted with ecore_thread_global_data_del() or
1900 * because Ecore Thread was shut down and the hash destroyed. This parameter
1901 * may be NULL, in which case @p value needs to be manually freed after
1902 * removing it from the hash with either ecore_thread_global_data_del() or
1903 * ecore_thread_global_data_set().
1905 * Manually freeing any data that was added to the hash with a @p cb function
1906 * is likely to produce a segmentation fault, or any other strange
1907 * happenings, later on in the program.
1909 * @see ecore_thread_global_data_del()
1910 * @see ecore_thread_global_data_set()
1911 * @see ecore_thread_global_data_find()
1913 EAPI Eina_Bool ecore_thread_global_data_add(const char *key, void *value, Eina_Free_Cb cb, Eina_Bool direct);
1915 * Sets some data in the hash shared by all threads
1917 * @param key The name under which the data will be stored
1918 * @param value The data to add
1919 * @param cb Function to free the data when removed from the hash
1921 * If no data exists in the hash under the @p key, this function adds
1922 * @p value in the hash under the given @p key and returns NULL.
1923 * The key itself is copied.
1925 * If the hash already contains something under @p key, the data will be
1926 * replaced by @p value and the old value will be returned.
1928 * NULL will also be returned if either @p key or @p value are NULL, or if
1929 * an error occurred.
1931 * @see ecore_thread_global_data_add()
1932 * @see ecore_thread_global_data_del()
1933 * @see ecore_thread_global_data_find()
1935 EAPI void *ecore_thread_global_data_set(const char *key, void *value, Eina_Free_Cb cb);
1937 * Gets data stored in the hash shared by all threads
1939 * @param key The name under which the data is stored
1940 * @return The value under the given key, or NULL on error
1942 * Finds and return the data stored in the shared hash under the key @p key.
1944 * Keep in mind that the data returned may be used by more than one thread
1945 * at the same time and no reference counting is done on it by Ecore.
1946 * Freeing the data or modifying its contents may require additional
1947 * precautions to be considered, depending on the application's design.
1949 * @see ecore_thread_global_data_add()
1950 * @see ecore_thread_global_data_wait()
1952 EAPI void *ecore_thread_global_data_find(const char *key);
1954 * Deletes from the shared hash the data corresponding to the given key
1956 * @param key The name under which the data is stored
1957 * @return EINA_TRUE on success, EINA_FALSE on failure
1959 * If there's any data stored associated with @p key in the global hash,
1960 * this function will remove it from it and return EINA_TRUE. If no data
1961 * exists or an error occurs, it returns EINA_FALSE.
1963 * If the data was added to the hash with a free function, then it will
1964 * also be freed after removing it from the hash, otherwise it requires
1965 * to be manually freed by the user, which means that if no other reference
1966 * to it exists before calling this function, it will result in a memory
1969 * Note, also, that freeing data that other threads may be using will result
1970 * in a crash, so appropriate care must be taken by the application when
1971 * that possibility exists.
1973 * @see ecore_thread_global_data_add()
1975 EAPI Eina_Bool ecore_thread_global_data_del(const char *key);
1977 * Gets data stored in the shared hash, or wait for it if it doesn't exist
1979 * @param key The name under which the data is stored
1980 * @param seconds The amount of time in seconds to wait for the data.
1981 * @return The value under the given key, or NULL on error
1983 * Finds and return the data stored in the shared hash under the key @p key.
1985 * If there's nothing in the hash under the given @p key, the function
1986 * will block and wait up to @p seconds seconds for some other thread to
1987 * add it with either ecore_thread_global_data_add() or
1988 * ecore_thread_global_data_set(). If after waiting there's still no data
1989 * to get, NULL will be returned.
1991 * If @p seconds is 0, then no waiting will happen and this function works
1992 * like ecore_thread_global_data_find(). If @p seconds is less than 0, then
1993 * the function will wait indefinitely.
1995 * Keep in mind that the data returned may be used by more than one thread
1996 * at the same time and no reference counting is done on it by Ecore.
1997 * Freeing the data or modifying its contents may require additional
1998 * precautions to be considered, depending on the application's design.
2000 * @see ecore_thread_global_data_add()
2001 * @see ecore_thread_global_data_find()
2003 EAPI void *ecore_thread_global_data_wait(const char *key, double seconds);
2010 * @defgroup Ecore_Pipe_Group Pipe wrapper
2012 * These functions wrap the pipe / write / read functions to easily
2013 * integrate its use into ecore's main loop.
2015 * The ecore_pipe_add() function creates file descriptors (sockets
2016 * on Windows) and attach a handle to the ecore main loop. That
2017 * handle is called when data is read in the pipe. To write data in
2018 * the pipe, just call ecore_pipe_write(). When you are done, just
2019 * call ecore_pipe_del().
2021 * For examples see here:
2022 * @li @ref tutorial_ecore_pipe_gstreamer_example
2023 * @li @ref tutorial_ecore_pipe_simple_example
2025 * @ingroup Ecore_Main_Loop_Group
2030 typedef struct _Ecore_Pipe Ecore_Pipe; /**< A handle for pipes */
2033 * @typedef Ecore_Pipe_Cb Ecore_Pipe_Cb
2034 * The callback that data written to the pipe is sent to.
2036 typedef void (*Ecore_Pipe_Cb) (void *data, void *buffer, unsigned int nbyte);
2038 EAPI Ecore_Pipe *ecore_pipe_add(Ecore_Pipe_Cb handler, const void *data);
2039 EAPI void *ecore_pipe_del(Ecore_Pipe *p);
2040 EAPI Eina_Bool ecore_pipe_write(Ecore_Pipe *p, const void *buffer, unsigned int nbytes);
2041 EAPI void ecore_pipe_write_close(Ecore_Pipe *p);
2042 EAPI void ecore_pipe_read_close(Ecore_Pipe *p);
2043 EAPI void ecore_pipe_thaw(Ecore_Pipe *p);
2044 EAPI void ecore_pipe_freeze(Ecore_Pipe *p);
2045 EAPI int ecore_pipe_wait(Ecore_Pipe *p, int message_count, double wait);
2052 * @defgroup Ecore_Job_Group Ecore Job functions
2054 * You can queue jobs that are to be done by the main loop when the
2055 * current event is dealt with.
2057 * Jobs are processed by the main loop similarly to events. They
2058 * also will be executed in the order in which they were added.
2060 * A good use for them is when you don't want to execute an action
2061 * immeditately, but want to give the control back to the main loop
2062 * so that it will call your job callback when jobs start being
2063 * processed (and if there are other jobs added before yours, they
2064 * will be processed first). This also gives the chance to other
2065 * actions in your program to cancel the job before it is started.
2067 * Examples of using @ref Ecore_Job:
2068 * @li @ref ecore_job_example_c
2070 * @ingroup Ecore_Main_Loop_Group
2075 typedef struct _Ecore_Job Ecore_Job; /**< A job handle */
2077 EAPI Ecore_Job *ecore_job_add(Ecore_Cb func, const void *data);
2078 EAPI void *ecore_job_del(Ecore_Job *job);
2085 * @defgroup Ecore_Application_Group Ecore Application functions
2090 EAPI void ecore_app_args_set(int argc, const char **argv);
2091 EAPI void ecore_app_args_get(int *argc, char ***argv);
2092 EAPI void ecore_app_restart(void);
2099 * @defgroup Ecore_Throttle_Group Ecore Throttle functions
2101 * @ingroup Ecore_Main_Loop_Group
2106 EAPI void ecore_throttle_adjust(double amount );
2107 EAPI double ecore_throttle_get(void);