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_Main_Loop_Group
23 @li @ref Ecore_File_Group
24 @li @ref Ecore_Con_Group
25 @li @link Ecore_Evas.h Ecore_Evas - Evas convenience functions. @endlink
26 @li @ref Ecore_FB_Group
27 @li @link Ecore_Ipc.h Ecore_IPC - Inter Process Communication functions. @endlink
28 @li @link Ecore_X.h Ecore_X - X Windows System wrapper. @endlink
29 @li @ref Ecore_Win32_Group
30 @li @ref Ecore_WinCE_Group
32 For more info on Ecore usage, there are these @ref Examples.
34 @section compiling How to compile using Ecore?
35 pkgconfig (.pc) files are installed for every ecore module.
36 Thus, to compile using any of them, you can use something like the following:
39 gcc *.c $(pkg-config ecore ecore-$x ecore-$y [...] --cflags --libs)
42 @section install How is it installed?
44 Suggested configure options for evas for a Linux desktop X display:
58 @author Carsten Haitzler <raster@rasterman.com>
59 @author Tom Gilbert <tom@linuxbrit.co.uk>
60 @author Burra <burra@colorado.edu>
61 @author Chris Ross <chris@darkrock.co.uk>
62 @author Term <term@twistedpath.org>
63 @author Tilman Sauerbeck <tilman@code-monkey.de>
64 @author Ibukun Olumuyiwa <ibukun@computer.org>
65 @author Yuri <da2001@hotmail.ru>
66 @author Nicholas Curran <quasar@bigblue.net.au>
67 @author Howell Tam <pigeon@pigeond.net>
68 @author Nathan Ingersoll <rbdpngn@users.sourceforge.net>
69 @author Andrew Elcock <andy@elcock.org>
70 @author Kim Woelders <kim@woelders.dk>
71 @author Sebastian Dransfeld <sebastid@tango.flipp.net>
72 @author Simon Poole <simon.armlinux@themalago.net>
73 @author Jorge Luis Zapata Muga <jorgeluis.zapata@gmail.com>
74 @author dan sinclair <zero@everburning.com>
75 @author Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de>
76 @author David 'onefang' Seikel <onefang@gmail.com>
77 @author Hisham 'CodeWarrior' Mardam Bey <hisham@hisham.cc>
78 @author Brian 'rephorm' Mattern <rephorm@rephorm.com>
79 @author Tim Horton <hortont424@gmail.com>
80 @author Arnaud de Turckheim 'quarium' <quarium@gmail.com>
81 @author Matt Barclay <mbarclay@gmail.com>
82 @author Peter Wehrfritz <peter.wehrfritz@web.de>
83 @author Albin "Lutin" Tonnerre <albin.tonnerre@gmail.com>
84 @author Vincent Torri <vincent.torri@gmail.com>
85 @author Lars Munch <lars@segv.dk>
86 @author Andre Dieb <andre.dieb@gmail.com>
87 @author Mathieu Taillefumier <mathieu.taillefumier@free.fr>
88 @author Rui Miguel Silva Seabra <rms@1407.org>
89 @author Samsung Electronics
91 @author Nicolas Aguirre <aguirre.nicolas@gmail.com>
92 @author Brett Nash <nash@nash.id.au>
93 @author Mike Blumenkrantz <mike@zentific.com>
94 @author Leif Middelschulte <leif.middelschulte@gmail.com>
95 @author Mike McCormack <mj.mccormack@samsung.com>
96 @author Sangho Park <gouache95@gmail.com>
97 @author Jihoon Kim <jihoon48.kim@samsung.com> <imfine98@gmail.com>
98 @author Daniel Juyung Seo <seojuyung2@gmail.com> <juyung.seo@samsung.com>
100 Please contact <enlightenment-devel@lists.sourceforge.net> to get in
101 contact with the developers and maintainers.
105 @page Ecore_Main_Loop_Page The Ecore Main Loop
107 @section intro What is Ecore?
109 Ecore is a clean and tiny event loop library with many modules to do lots of
110 convenient things for a programmer, to save time and effort.
112 It's small and lean, designed to work on embedded systems all the way to
113 large and powerful multi-cpu workstations. It serialises all system signals,
114 events etc. into a single event queue, that is easily processed without
115 needing to worry about concurrency. A properly written, event-driven program
116 using this kind of programming doesn't need threads, nor has to worry about
117 concurrency. It turns a program into a state machine, and makes it very
118 robust and easy to follow.
120 Ecore gives you other handy primitives, such as timers to tick over for you
121 and call specified functions at particular times so the programmer can use
122 this to do things, like animate, or time out on connections or tasks that take
125 Idle handlers are provided too, as well as calls on entering an idle state
126 (often a very good time to update the state of the program). All events that
127 enter the system are passed to specific callback functions that the program
128 sets up to handle those events. Handling them is simple and other Ecore
129 modules produce more events on the queue, coming from other sources such as
130 file descriptors etc.
132 Ecore also lets you have functions called when file descriptors become active
133 for reading or writing, allowing for streamlined, non-blocking IO.
135 Here is an example of a simple program and its basic event loop flow:
137 @image html prog_flow.png
138 @image latex prog_flow.eps width=\textwidth
142 @section work How does Ecore work?
144 Ecore is very easy to learn and use. All the function calls are designed to
145 be easy to remember, explicit in describing what they do, and heavily
146 name-spaced. Ecore programs can start and be very simple.
153 int main(int argc, const char **argv)
156 ecore_app_args_set(argc, argv);
157 ecore_main_loop_begin();
163 This program is very simple and doesn't check for errors, but it does start up
164 and begin a main loop waiting for events or timers to tick off. This program
165 doesn't set up any, but now we can expand on this simple program a little
166 more by adding some event handlers and timers.
171 Ecore_Timer *timer1 = NULL;
172 Ecore_Event_Handler *handler1 = NULL;
173 double start_time = 0.0;
175 int timer_func(void *data)
177 printf("Tick timer. Sec: %3.2f\n", ecore_time_get() - start_time);
181 int exit_func(void *data, int ev_type, void *ev)
183 Ecore_Event_Signal_Exit *e;
185 e = (Ecore_Event_Signal_Exit *)ev;
186 if (e->interrupt) printf("Exit: interrupt\n");
187 else if (e->quit) printf("Exit: quit\n");
188 else if (e->terminate) printf("Exit: terminate\n");
189 ecore_main_loop_quit();
193 int main(int argc, const char **argv)
196 ecore_app_args_set(argc, argv);
197 start_time = ecore_time_get();
198 handler1 = ecore_event_handler_add(ECORE_EVENT_SIGNAL_EXIT, exit_func, NULL);
199 timer1 = ecore_timer_add(0.5, timer_func, NULL);
200 ecore_main_loop_begin();
206 In the previous example, we initialize our application and get the time at
207 which our program has started so we can calculate an offset. We set
208 up a timer to tick off in 0.5 seconds, and since it returns 1, will
209 keep ticking off every 0.5 seconds until it returns 0, or is deleted
210 by hand. An event handler is set up to call a function - exit_func(),
211 whenever an event of type ECORE_EVENT_SIGNAL_EXIT is received (CTRL-C
212 on the command line will cause such an event to happen). If this event
213 occurs it tells you what kind of exit signal was received, and asks
214 the main loop to quit when it is finished by calling
215 ecore_main_loop_quit().
217 The handles returned by ecore_timer_add() and ecore_event_handler_add() are
218 only stored here as an example. If you don't need to address the timer or
219 event handler again you don't need to store the result, so just call the
220 function, and don't assign the result to any variable.
222 This program looks slightly more complex than needed to do these simple
223 things, but in principle, programs don't get any more complex. You add more
224 event handlers, for more events, will have more timers and such, BUT it all
225 follows the same principles as shown in this example.
230 @page Ecore_Config_Page The Enlightened Property Library
232 The Enlightened Property Library (Ecore_Config) is an adbstraction
233 from the complexities of writing your own configuration. It provides
234 many features using the Enlightenment 17 development libraries.
236 To use the library, you:
237 @li Set the default values of your properties.
238 @li Load the configuration from a file. You must set the default values
239 first, so that the library knows the correct type of each argument.
241 The following examples show how to use the Enlightened Property Library:
242 @li @link config_basic_example.c config_basic_example.c @endlink
243 @li @link config_listener_example.c config_listener_example.c @endlink
248 @page X_Window_System_Page X Window System
250 The Ecore library includes a wrapper for handling the X window system.
251 This page briefly explains what the X window system is and various terms
269 # ifdef EFL_ECORE_BUILD
271 # define EAPI __declspec(dllexport)
274 # endif /* ! DLL_EXPORT */
276 # define EAPI __declspec(dllimport)
277 # endif /* ! EFL_ECORE_BUILD */
281 # define EAPI __attribute__ ((visibility("default")))
288 #endif /* ! _WIN32 */
291 # include <winsock2.h>
292 #elif (defined (__FreeBSD__) && (__FreeBSD_version >= 420001)) || defined (__OpenBSD__)
293 # include <sys/select.h>
296 # include <sys/time.h>
300 #include <sys/types.h>
307 * @defgroup Ecore_Init_Group Ecore initialization and shutdown functions.
312 EAPI int ecore_init(void);
313 EAPI int ecore_shutdown(void);
321 * @defgroup Ecore_Main_Loop_Group Ecore main loop functions
323 * These are functions acting on Ecore's main loop itself or on
324 * events and infrastructure directly linked to it. This loop is
325 * designed to work on embedded systems all the way to large and
326 * powerful multi-cpu workstations.
328 * It serialises all system signals and events into a single event
329 * queue, that can be easily processed without needing to worry
330 * about concurrency. A properly written, event-driven program
331 * using this kind of programming does not need threads. It makes
332 * the program very robust and easy to follow.
334 * For example, for the main loop to be of any use, you need to be
335 * able to add @b events and event handlers on it. Events for file
336 * descriptor events are covered in @ref Ecore_FD_Handler_Group.
338 * Timer functions are covered in @ref Ecore_Time_Group.
340 * There is also provision for callbacks for when the loop enters or
341 * exits an @b idle state. See @ref Ecore_Idle_Group for more
344 * Functions are also provided for spawning child processes using
345 * @c fork(). See @ref Ecore_Exe_Group for more details on it.
347 * Here is an example of simple program and its basic event loop
350 * @image html prog_flow.png
351 * @image latex prog_flow.eps width=\textwidth
353 * For examples of setting up and using a main loop, see
354 * @ref Ecore_Main_Loop_Page.
359 #define ECORE_VERSION_MAJOR 1
360 #define ECORE_VERSION_MINOR 0
362 typedef struct _Ecore_Version
370 EAPI extern Ecore_Version *ecore_version;
372 #define ECORE_CALLBACK_CANCEL EINA_FALSE /**< Return value to remove a callback */
373 #define ECORE_CALLBACK_RENEW EINA_TRUE /**< Return value to keep a callback */
375 #define ECORE_CALLBACK_PASS_ON EINA_TRUE /**< Return value to pass event to next handler */
376 #define ECORE_CALLBACK_DONE EINA_FALSE /**< Return value to stop event handling */
379 * @typedef Ecore_Task_Cb Ecore_Task_Cb
380 * A callback run for a task (timer, idler, poller, animator, etc)
382 typedef Eina_Bool (*Ecore_Task_Cb) (void *data);
385 * @typedef Ecore_Eselect_Function Ecore_Eselect_Function
386 * A function which can be used to replace select() in the main loop
388 typedef int (*Ecore_Select_Function)(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout);
390 EAPI void ecore_main_loop_iterate(void);
392 EAPI void ecore_main_loop_select_func_set(Ecore_Select_Function func);
393 EAPI Ecore_Select_Function ecore_main_loop_select_func_get(void);
395 EAPI Eina_Bool ecore_main_loop_glib_integrate(void);
396 EAPI void ecore_main_loop_glib_always_integrate_disable(void);
398 EAPI void ecore_main_loop_begin(void);
399 EAPI void ecore_main_loop_quit(void);
402 * @typedef Ecore_Cb Ecore_Cb
403 * A generic callback called as a hook when a certain point in
404 * execution is reached.
406 typedef void (*Ecore_Cb) (void *data);
409 * @typedef Ecore_Data_Cb Ecore_Data_Cb
410 * A callback which is used to return data to the main function
412 typedef void *(*Ecore_Data_Cb) (void *data);
415 * @brief Call callback asynchronously in the main loop.
418 * @param callback The callback to call in the main loop
419 * @param data The data to give to that call back
421 * For all calls that need to happen in the main loop (most EFL functions do),
422 * this helper function provides the infrastructure needed to do it safely
423 * by avoiding dead lock, race condition and properly wake up the main loop.
425 * Remember after that function call, you should never touch again the @p data
426 * in the thread, it is owned by the main loop and your callback should take
427 * care of freeing it if necessary.
429 EAPI void ecore_main_loop_thread_safe_call_async(Ecore_Cb callback, void *data);
432 * @brief Call callback synchronously in the main loop.
435 * @param callback The callback to call in the main loop
436 * @param data The data to give to that call back
437 * @return the value returned by the callback in the main loop
439 * For all calls that need to happen in the main loop (most EFL functions do),
440 * this helper function provides the infrastructure needed to do it safely
441 * by avoiding dead lock, race condition and properly wake up the main loop.
443 * Remember this function will block until the callback is executed in the
444 * main loop. It can take time and you have no guaranty about the timeline.
446 EAPI void *ecore_main_loop_thread_safe_call_sync(Ecore_Data_Cb callback, void *data);
449 * @brief This function suspend the main loop in a know state
452 * @result the number of time ecore_thread_main_loop_begin() has been called
453 * in this thread, if the main loop was suspended correctly. If not, it return @c -1.
455 * This function suspend the main loop in a know state, this let you
456 * use any EFL call you want after it return. Be carefull, the main loop
457 * is blocked until you call ecore_thread_main_loop_end(). This is
458 * the only sane way to achieve pseudo thread safety.
460 * Notice that until the main loop is blocked, the thread is blocked
461 * and their is noway around that.
463 * We still advise you, when possible, to use ecore_main_loop_thread_safe_call_async()
464 * as it will not block the thread nor the main loop.
466 EAPI int ecore_thread_main_loop_begin(void);
469 * @brief Unlock the main loop.
472 * @result the number of time ecore_thread_main_loop_end() need to be called before
473 * the main loop is unlocked again. @c -1 will be returned if you are trying to unlock
474 * when there wasn't enough call to ecore_thread_main_loop_begin().
476 * After a call to ecore_thread_main_loop_begin(), you need to absolutly
477 * call ecore_thread_main_loop_end(), or you application will stay frozen.
479 EAPI int ecore_thread_main_loop_end(void);
486 * @defgroup Ecore_Event_Group Ecore Event functions
488 * Ecore events are used to wake up the Ecore main loop to warn
489 * about state changes, tasks completed, data available for reading
490 * or writing, etc. They are the base of the event oriented
493 * The idea is to write many functions (callbacks) that will be
494 * registered to specific events, and called when these events
495 * happen. This way, when the system state changes (a mouse click is
496 * detected, a key is pressed, or the content of a file changes, for
497 * example), the respective callbacks will be called with some
498 * information about that event. Usually the function/callback will
499 * have a data pointer to the event info (the position in the screen
500 * where the mouse was clicked, the name of the key that was
501 * pressed, or the name of the file that has changed).
503 * The basic usage, when one needs to watch for an existing event,
504 * is to register a callback to it using ecore_event_add(). Of
505 * course it's necessary to know beforehand what are the types of
506 * events that the system/library will emmit. This should be
507 * available with the documentation from that system/library.
509 * When writing a library or group of functions that need to inform
510 * about something, and you already are running on top of a main
511 * loop, it is usually a good approach to use events. This way you
512 * allow others to register as many callbacks as necessary to this
513 * event, and don't have to care about who is registering to it. The
514 * functions ecore_event_type_new() and ecore_event_add() are
515 * available for this purpose.
517 * Example that deals with events:
519 * @li @ref ecore_event_example_c
521 * @ingroup Ecore_Main_Loop_Group
526 #define ECORE_EVENT_NONE 0
527 #define ECORE_EVENT_SIGNAL_USER 1 /**< User signal event */
528 #define ECORE_EVENT_SIGNAL_HUP 2 /**< Hup signal event */
529 #define ECORE_EVENT_SIGNAL_EXIT 3 /**< Exit signal event */
530 #define ECORE_EVENT_SIGNAL_POWER 4 /**< Power signal event */
531 #define ECORE_EVENT_SIGNAL_REALTIME 5 /**< Realtime signal event */
532 #define ECORE_EVENT_COUNT 6
534 typedef struct _Ecore_Win32_Handler Ecore_Win32_Handler; /**< A handle for HANDLE handlers on Windows */
535 typedef struct _Ecore_Event_Handler Ecore_Event_Handler; /**< A handle for an event handler */
536 typedef struct _Ecore_Event_Filter Ecore_Event_Filter; /**< A handle for an event filter */
537 typedef struct _Ecore_Event Ecore_Event; /**< A handle for an event */
538 typedef struct _Ecore_Event_Signal_User Ecore_Event_Signal_User; /**< User signal event */
539 typedef struct _Ecore_Event_Signal_Hup Ecore_Event_Signal_Hup; /**< Hup signal event */
540 typedef struct _Ecore_Event_Signal_Exit Ecore_Event_Signal_Exit; /**< Exit signal event */
541 typedef struct _Ecore_Event_Signal_Power Ecore_Event_Signal_Power; /**< Power signal event */
542 typedef struct _Ecore_Event_Signal_Realtime Ecore_Event_Signal_Realtime; /**< Realtime signal event */
545 * @typedef Ecore_Filter_Cb
546 * A callback used for filtering events from the main loop.
548 typedef Eina_Bool (*Ecore_Filter_Cb) (void *data, void *loop_data, int type, void *event);
551 * @typedef Ecore_End_Cb Ecore_End_Cb
552 * This is the callback which is called at the end of a function,
553 * usually for cleanup purposes.
555 typedef void (*Ecore_End_Cb) (void *user_data, void *func_data);
558 * @typedef Ecore_Event_Handler_Cb Ecore_Event_Handler_Cb
559 * A callback used by the main loop to handle events of a specified
562 typedef Eina_Bool (*Ecore_Event_Handler_Cb) (void *data, int type, void *event);
564 struct _Ecore_Event_Signal_User /** User signal event */
566 int number; /**< The signal number. Either 1 or 2 */
567 void *ext_data; /**< Extension data - not used */
570 siginfo_t data; /**< Signal info */
574 struct _Ecore_Event_Signal_Hup /** Hup signal event */
576 void *ext_data; /**< Extension data - not used */
579 siginfo_t data; /**< Signal info */
583 struct _Ecore_Event_Signal_Exit /** Exit request event */
585 Eina_Bool interrupt : 1; /**< Set if the exit request was an interrupt signal*/
586 Eina_Bool quit : 1; /**< set if the exit request was a quit signal */
587 Eina_Bool terminate : 1; /**< Set if the exit request was a terminate singal */
588 void *ext_data; /**< Extension data - not used */
591 siginfo_t data; /**< Signal info */
595 struct _Ecore_Event_Signal_Power /** Power event */
597 void *ext_data; /**< Extension data - not used */
600 siginfo_t data; /**< Signal info */
604 struct _Ecore_Event_Signal_Realtime /** Realtime event */
606 int num; /**< The realtime signal's number */
609 siginfo_t data; /**< Signal info */
613 EAPI Ecore_Event_Handler *ecore_event_handler_add(int type, Ecore_Event_Handler_Cb func, const void *data);
614 EAPI void *ecore_event_handler_del(Ecore_Event_Handler *event_handler);
615 EAPI Ecore_Event *ecore_event_add(int type, void *ev, Ecore_End_Cb func_free, void *data);
616 EAPI void *ecore_event_del(Ecore_Event *event);
617 EAPI void *ecore_event_handler_data_get(Ecore_Event_Handler *eh);
618 EAPI void *ecore_event_handler_data_set(Ecore_Event_Handler *eh, const void *data);
619 EAPI int ecore_event_type_new(void);
620 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);
621 EAPI void *ecore_event_filter_del(Ecore_Event_Filter *ef);
622 EAPI int ecore_event_current_type_get(void);
623 EAPI void *ecore_event_current_event_get(void);
630 * @defgroup Ecore_Exe_Group Process Spawning Functions
632 * Functions that deal with and send signals to spawned processes.
634 * @ingroup Ecore_Main_Loop_Group
639 #define ECORE_EXE_PRIORITY_INHERIT 9999
641 EAPI extern int ECORE_EXE_EVENT_ADD; /**< A child process has been added */
642 EAPI extern int ECORE_EXE_EVENT_DEL; /**< A child process has been deleted (it exited, naming consistent with the rest of ecore). */
643 EAPI extern int ECORE_EXE_EVENT_DATA; /**< Data from a child process. */
644 EAPI extern int ECORE_EXE_EVENT_ERROR; /**< Errors from a child process. */
646 enum _Ecore_Exe_Flags /* flags for executing a child with its stdin and/or stdout piped back */
648 ECORE_EXE_NONE = 0, /**< No exe flags at all */
649 ECORE_EXE_PIPE_READ = 1, /**< Exe Pipe Read mask */
650 ECORE_EXE_PIPE_WRITE = 2, /**< Exe Pipe Write mask */
651 ECORE_EXE_PIPE_ERROR = 4, /**< Exe Pipe error mask */
652 ECORE_EXE_PIPE_READ_LINE_BUFFERED = 8, /**< Reads are buffered until a newline and split 1 line per Ecore_Exe_Event_Data_Line */
653 ECORE_EXE_PIPE_ERROR_LINE_BUFFERED = 16, /**< Errors are buffered until a newline and split 1 line per Ecore_Exe_Event_Data_Line */
654 ECORE_EXE_PIPE_AUTO = 32, /**< stdout and stderr are buffered automatically */
655 ECORE_EXE_RESPAWN = 64, /**< FIXME: Exe is restarted if it dies */
656 ECORE_EXE_USE_SH = 128, /**< Use /bin/sh to run the command. */
657 ECORE_EXE_NOT_LEADER = 256 /**< Do not use setsid() to have the executed process be its own session leader */
659 typedef enum _Ecore_Exe_Flags Ecore_Exe_Flags;
661 enum _Ecore_Exe_Win32_Priority
663 ECORE_EXE_WIN32_PRIORITY_IDLE, /**< Idle priority, for monitoring the system */
664 ECORE_EXE_WIN32_PRIORITY_BELOW_NORMAL, /**< Below default priority */
665 ECORE_EXE_WIN32_PRIORITY_NORMAL, /**< Default priority */
666 ECORE_EXE_WIN32_PRIORITY_ABOVE_NORMAL, /**< Above default priority */
667 ECORE_EXE_WIN32_PRIORITY_HIGH, /**< High priority, use with care as other threads in the system will not get processor time */
668 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 */
670 typedef enum _Ecore_Exe_Win32_Priority Ecore_Exe_Win32_Priority;
672 typedef struct _Ecore_Exe Ecore_Exe; /**< A handle for spawned processes */
675 * @typedef Ecore_Exe_Cb Ecore_Exe_Cb
676 * A callback to run with the associated @ref Ecore_Exe, usually
677 * for cleanup purposes.
679 typedef void (*Ecore_Exe_Cb)(void *data, const Ecore_Exe *exe);
681 typedef struct _Ecore_Exe_Event_Add Ecore_Exe_Event_Add; /**< Spawned Exe add event */
682 typedef struct _Ecore_Exe_Event_Del Ecore_Exe_Event_Del; /**< Spawned Exe exit event */
683 typedef struct _Ecore_Exe_Event_Data_Line Ecore_Exe_Event_Data_Line; /**< Lines from a child process */
684 typedef struct _Ecore_Exe_Event_Data Ecore_Exe_Event_Data; /**< Data from a child process */
686 struct _Ecore_Exe_Event_Add /** Process add event */
688 Ecore_Exe *exe; /**< The handle to the added process */
689 void *ext_data; /**< Extension data - not used */
692 struct _Ecore_Exe_Event_Del /** Process exit event */
694 pid_t pid; /**< The process ID of the process that exited */
695 int exit_code; /**< The exit code of the process */
696 Ecore_Exe *exe; /**< The handle to the exited process, or NULL if not found */
697 int exit_signal; /** < The signal that caused the process to exit */
698 Eina_Bool exited : 1; /** < set to 1 if the process exited of its own accord */
699 Eina_Bool signalled : 1; /** < set to 1 id the process exited due to uncaught signal */
700 void *ext_data; /**< Extension data - not used */
702 siginfo_t data; /**< Signal info */
706 struct _Ecore_Exe_Event_Data_Line /**< Lines from a child process */
712 struct _Ecore_Exe_Event_Data /** Data from a child process event */
714 Ecore_Exe *exe; /**< The handle to the process */
715 void *data; /**< the raw binary data from the child process that was received */
716 int size; /**< the size of this data in bytes */
717 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 */
720 EAPI void ecore_exe_run_priority_set(int pri);
721 EAPI int ecore_exe_run_priority_get(void);
722 EAPI Ecore_Exe *ecore_exe_run(const char *exe_cmd, const void *data);
723 EAPI Ecore_Exe *ecore_exe_pipe_run(const char *exe_cmd, Ecore_Exe_Flags flags, const void *data);
724 EAPI void ecore_exe_callback_pre_free_set(Ecore_Exe *exe, Ecore_Exe_Cb func);
725 EAPI Eina_Bool ecore_exe_send(Ecore_Exe *exe, const void *data, int size);
726 EAPI void ecore_exe_close_stdin(Ecore_Exe *exe);
727 EAPI void ecore_exe_auto_limits_set(Ecore_Exe *exe, int start_bytes, int end_bytes, int start_lines, int end_lines);
728 EAPI Ecore_Exe_Event_Data *ecore_exe_event_data_get(Ecore_Exe *exe, Ecore_Exe_Flags flags);
729 EAPI void ecore_exe_event_data_free(Ecore_Exe_Event_Data *data);
730 EAPI void *ecore_exe_free(Ecore_Exe *exe);
731 EAPI pid_t ecore_exe_pid_get(const Ecore_Exe *exe);
732 EAPI void ecore_exe_tag_set(Ecore_Exe *exe, const char *tag);
733 EAPI const char *ecore_exe_tag_get(const Ecore_Exe *exe);
734 EAPI const char *ecore_exe_cmd_get(const Ecore_Exe *exe);
735 EAPI void *ecore_exe_data_get(const Ecore_Exe *exe);
736 EAPI void *ecore_exe_data_set(Ecore_Exe *exe, void *data);
737 EAPI Ecore_Exe_Flags ecore_exe_flags_get(const Ecore_Exe *exe);
738 EAPI void ecore_exe_pause(Ecore_Exe *exe);
739 EAPI void ecore_exe_continue(Ecore_Exe *exe);
740 EAPI void ecore_exe_interrupt(Ecore_Exe *exe);
741 EAPI void ecore_exe_quit(Ecore_Exe *exe);
742 EAPI void ecore_exe_terminate(Ecore_Exe *exe);
743 EAPI void ecore_exe_kill(Ecore_Exe *exe);
744 EAPI void ecore_exe_signal(Ecore_Exe *exe, int num);
745 EAPI void ecore_exe_hup(Ecore_Exe *exe);
752 * @defgroup Ecore_FD_Handler_Group File Event Handling Functions
754 * Functions that deal with file descriptor handlers.
756 * The @ref Ecore_Fd_Handler can be used to watch a file descriptor
757 * for data available for reading, for the availability to write
758 * without blocking, and for errors on the file descriptor.
760 * ecore_main_fd_handler_add() is used to setup a handler for a
761 * given file descriptor. This file descriptor can be the standard
762 * input, a network socket, a stream received through some driver
763 * of a hardware decoder, etc. Thus it can contain errors, like a
764 * disconnection, a broken pipe, and so, and that's why it's
765 * possible to check for these errors with the @ref ECORE_FD_ERROR
768 * An @ref Ecore_Fd_Handler can be used to watch on a file
769 * descriptor without blocking, still being able to receive events,
770 * expire timers, and other watch for other things that happen in
771 * the Ecore main loop.
773 * Example of use of a file descriptor handler:
774 * @li @ref ecore_fd_handler_example_c
776 * @ingroup Ecore_Main_Loop_Group
781 typedef struct _Ecore_Fd_Handler Ecore_Fd_Handler; /**< A handle for Fd handlers */
783 enum _Ecore_Fd_Handler_Flags
785 ECORE_FD_READ = 1, /**< Fd Read mask */
786 ECORE_FD_WRITE = 2, /**< Fd Write mask */
787 ECORE_FD_ERROR = 4 /**< Fd Error mask */
789 typedef enum _Ecore_Fd_Handler_Flags Ecore_Fd_Handler_Flags;
792 * @typedef Ecore_Fd_Cb Ecore_Fd_Cb
793 * A callback used by an @ref Ecore_Fd_Handler.
795 typedef Eina_Bool (*Ecore_Fd_Cb) (void *data, Ecore_Fd_Handler *fd_handler);
798 * @typedef Ecore_Fd_Prep_Cb Ecore_Fd_Prep_Cb
799 * A callback used by an @ref Ecore_Fd_Handler.
801 typedef void (*Ecore_Fd_Prep_Cb) (void *data, Ecore_Fd_Handler *fd_handler);
804 * @typedef Ecore_Win32_Handle_Cb Ecore_Win32_Handle_Cb
805 * A callback used by an @ref Ecore_Win32_Handler.
807 typedef Eina_Bool (*Ecore_Win32_Handle_Cb) (void *data, Ecore_Win32_Handler *wh);
809 EAPI Ecore_Fd_Handler *ecore_main_fd_handler_add(int fd, Ecore_Fd_Handler_Flags flags, Ecore_Fd_Cb func, const void *data,
810 Ecore_Fd_Cb buf_func, const void *buf_data);
811 EAPI void ecore_main_fd_handler_prepare_callback_set(Ecore_Fd_Handler *fd_handler, Ecore_Fd_Prep_Cb func, const void *data);
812 EAPI void *ecore_main_fd_handler_del(Ecore_Fd_Handler *fd_handler);
813 EAPI int ecore_main_fd_handler_fd_get(Ecore_Fd_Handler *fd_handler);
814 EAPI Eina_Bool ecore_main_fd_handler_active_get(Ecore_Fd_Handler *fd_handler, Ecore_Fd_Handler_Flags flags);
815 EAPI void ecore_main_fd_handler_active_set(Ecore_Fd_Handler *fd_handler, Ecore_Fd_Handler_Flags flags);
817 EAPI Ecore_Win32_Handler *ecore_main_win32_handler_add(void *h, Ecore_Win32_Handle_Cb func, const void *data);
818 EAPI void *ecore_main_win32_handler_del(Ecore_Win32_Handler *win32_handler);
825 * @defgroup Ecore_Poller_Group Ecore Poll functions
827 * These functions are for the need to poll information, but provide
828 * a shared abstracted API to pool such polling to minimise wakeup
829 * and ensure all the polling happens in as few spots as possible
830 * areound a core poll interval. For now only 1 core poller type is
831 * supprted: ECORE_POLLER_CORE
833 * Example of @ref Ecore_Poller:
834 * @li @ref ecore_poller_example_c
836 * @ingroup Ecore_Main_Loop_Group
841 enum _Ecore_Poller_Type /* Poller types */
843 ECORE_POLLER_CORE = 0 /**< The core poller interval */
845 typedef enum _Ecore_Poller_Type Ecore_Poller_Type;
847 typedef struct _Ecore_Poller Ecore_Poller; /**< A handle for pollers */
849 EAPI void ecore_poller_poll_interval_set(Ecore_Poller_Type type, double poll_time);
850 EAPI double ecore_poller_poll_interval_get(Ecore_Poller_Type type);
851 EAPI Eina_Bool ecore_poller_poller_interval_set(Ecore_Poller *poller, int interval);
852 EAPI int ecore_poller_poller_interval_get(Ecore_Poller *poller);
853 EAPI Ecore_Poller *ecore_poller_add(Ecore_Poller_Type type, int interval, Ecore_Task_Cb func, const void *data);
854 EAPI void *ecore_poller_del(Ecore_Poller *poller);
861 * @defgroup Ecore_Animator_Group Ecore Animator functions
863 * @brief Ecore animators are a helper to simplify creating
866 * Creating an animation is as simple as saying for how long it
867 * should be run and having a callback that does the animation,
868 * something like this:
871 * _do_animation(void *data, double pos)
873 * evas_object_move(data, 100 * pos, 100 * pos);
874 * ... do some more animating ...
877 * ecore_animator_timeline_add(2, _do_animation, my_evas_object);
879 * In the sample above we create an animation to move
880 * @c my_evas_object from position (0,0) to (100,100) in 2 seconds.
882 * If your animation will run for an unspecified amount of time you
883 * can use ecore_animator_add(), which is like using
884 * ecore_timer_add() with the interval being the
885 * @ref ecore_animator_frametime_set "framerate". Note that this has
886 * tangible benefits to creating a timer for each animation in terms
889 * For a more detailed example that show several animation see
890 * @ref tutorial_ecore_animator.
892 * @ingroup Ecore_Main_Loop_Group
897 typedef struct _Ecore_Animator Ecore_Animator; /**< A handle for animators */
899 enum _Ecore_Pos_Map /* Position mappings */
901 ECORE_POS_MAP_LINEAR, /**< Linear 0.0 -> 1.0 */
902 ECORE_POS_MAP_ACCELERATE, /**< Start slow then speed up */
903 ECORE_POS_MAP_DECELERATE, /**< Start fast then slow down */
904 ECORE_POS_MAP_SINUSOIDAL, /**< Start slow, speed up then slow down at end */
905 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. */
906 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. */
907 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. */
908 ECORE_POS_MAP_DIVISOR_INTERP, /**< Start at gradient * v1, interpolated via power of v2 curve */
909 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 */
910 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 */
912 typedef enum _Ecore_Pos_Map Ecore_Pos_Map;
914 enum _Ecore_Animator_Source /* Timing sources for animators */
916 ECORE_ANIMATOR_SOURCE_TIMER, /**< The default system clock/timer based animator that ticks every "frametime" seconds */
917 ECORE_ANIMATOR_SOURCE_CUSTOM /**< A custom animator trigger that you need to call ecore_animator_trigger() to make it tick */
919 typedef enum _Ecore_Animator_Source Ecore_Animator_Source;
922 * @typedef Ecore_Timeline_Cb Ecore_Timeline_Cb
923 * A callback run for a task (animators with runtimes)
925 typedef Eina_Bool (*Ecore_Timeline_Cb) (void *data, double pos);
928 * @brief Add an animator to call @p func at every animaton tick during main
931 * @param func The function to call when it ticks off
932 * @param data The data to pass to the function
933 * @return A handle to the new animator
935 * This function adds a animator and returns its handle on success and NULL on
936 * failure. The function @p func will be called every N seconds where N is the
937 * @p frametime interval set by ecore_animator_frametime_set(). The function
938 * will be passed the @p data pointer as its parameter.
940 * When the animator @p func is called, it must return a value of either 1 or
941 * 0. If it returns 1 (or ECORE_CALLBACK_RENEW), it will be called again at
942 * the next tick, or if it returns 0 (or ECORE_CALLBACK_CANCEL) it will be
943 * deleted automatically making any references/handles for it invalid.
945 * @note The default @p frametime value is 1/30th of a second.
947 * @see ecore_animator_timeline_add()
948 * @see ecore_animator_frametime_set()
950 EAPI Ecore_Animator *ecore_animator_add(Ecore_Task_Cb func, const void *data);
952 * @brief Add a animator that runs for a limited time
954 * @param runtime The time to run in seconds
955 * @param func The function to call when it ticks off
956 * @param data The data to pass to the function
957 * @return A handle to the new animator
959 * This function is just like ecore_animator_add() except the animator only
960 * runs for a limited time specified in seconds by @p runtime. Once the
961 * runtime the animator has elapsed (animator finished) it will automatically
962 * be deleted. The callback function @p func can return ECORE_CALLBACK_RENEW
963 * to keep the animator running or ECORE_CALLBACK_CANCEL ro stop it and have
964 * it be deleted automatically at any time.
966 * The @p func will ALSO be passed a position parameter that will be in value
967 * from 0.0 to 1.0 to indicate where along the timeline (0.0 start, 1.0 end)
968 * the animator run is at. If the callback wishes not to have a linear
969 * transition it can "map" this value to one of several curves and mappings
970 * via ecore_animator_pos_map().
972 * @note The default @p frametime value is 1/30th of a second.
974 * @see ecore_animator_add()
975 * @see ecore_animator_pos_map()
978 EAPI Ecore_Animator *ecore_animator_timeline_add(double runtime, Ecore_Timeline_Cb func, const void *data);
980 * @brief Delete the specified animator from the animator list.
982 * @param animator The animator to delete
983 * @return The data pointer set for the animator on add
985 * Delete the specified @p animator from the set of animators that are
986 * executed during main loop execution. This function returns the data
987 * parameter that was being passed to the callback on success, or NULL on
988 * failure. After this call returns the specified animator object @p animator
989 * is invalid and should not be used again. It will not get called again after
992 EAPI void *ecore_animator_del(Ecore_Animator *animator);
994 * @brief Suspend the specified animator.
996 * @param animator The animator to delete
998 * The specified @p animator will be temporarly removed from the set of
999 * animators that are executed during main loop.
1001 * @warning Freezing an animator doesn't freeze accounting of how long that
1002 * animator has been running. Therefore if the animator was created with
1003 * ecore_animator_timeline_add() the @p pos argument given to the callback
1004 * will increase as if the animator hadn't been frozen and the animator may
1005 * have it's execution halted if @p runtime elapsed.
1007 EAPI void ecore_animator_freeze(Ecore_Animator *animator);
1009 * @brief Restore execution of the specified animator.
1011 * @param animator The animator to delete
1013 * The specified @p animator will be put back in the set of animators that are
1014 * executed during main loop.
1016 EAPI void ecore_animator_thaw(Ecore_Animator *animator);
1018 * @brief Set the animator call interval in seconds.
1020 * @param frametime The time in seconds in between animator ticks.
1022 * This function sets the time interval (in seconds) between animator ticks.
1023 * At every tick the callback of every existing animator will be called.
1025 * @warning Too small a value may cause performance issues and too high a
1026 * value may cause your animation to seem "jerky".
1028 * @note The default @p frametime value is 1/30th of a second.
1030 EAPI void ecore_animator_frametime_set(double frametime);
1032 * @brief Get the animator call interval in seconds.
1034 * @return The time in second in between animator ticks.
1036 * This function retrieves the time in seconds between animator ticks.
1038 * @see ecore_animator_frametime_set()
1040 EAPI double ecore_animator_frametime_get(void);
1042 * @brief Maps an input position from 0.0 to 1.0 along a timeline to a
1043 * position in a different curve.
1045 * @param pos The input position to map
1046 * @param map The mapping to use
1047 * @param v1 A parameter use by the mapping (pass 0.0 if not used)
1048 * @param v2 A parameter use by the mapping (pass 0.0 if not used)
1049 * @return The mapped value
1051 * Takes an input position (0.0 to 1.0) and maps to a new position (normally
1052 * between 0.0 and 1.0, but it may go above/below 0.0 or 1.0 to show that it
1053 * has "overshot" the mark) using some interpolation (mapping) algorithm.
1055 * This function useful to create non-linear animations. It offers a variety
1056 * of possible animaton curves to be used:
1057 * @li ECORE_POS_MAP_LINEAR - Linear, returns @p pos
1058 * @li ECORE_POS_MAP_ACCELERATE - Start slow then speed up
1059 * @li ECORE_POS_MAP_DECELERATE - Start fast then slow down
1060 * @li ECORE_POS_MAP_SINUSOIDAL - Start slow, speed up then slow down at end
1061 * @li ECORE_POS_MAP_ACCELERATE_FACTOR - Start slow then speed up, v1 being a
1062 * power factor, 0.0 being linear, 1.0 being ECORE_POS_MAP_ACCELERATE, 2.0
1063 * being much more pronounced accelerate (squared), 3.0 being cubed, etc.
1064 * @li ECORE_POS_MAP_DECELERATE_FACTOR - Start fast then slow down, v1 being a
1065 * power factor, 0.0 being linear, 1.0 being ECORE_POS_MAP_DECELERATE, 2.0
1066 * being much more pronounced decelerate (squared), 3.0 being cubed, etc.
1067 * @li ECORE_POS_MAP_SINUSOIDAL_FACTOR - Start slow, speed up then slow down
1068 * at end, v1 being a power factor, 0.0 being linear, 1.0 being
1069 * ECORE_POS_MAP_SINUSOIDAL, 2.0 being much more pronounced sinusoidal
1070 * (squared), 3.0 being cubed, etc.
1071 * @li ECORE_POS_MAP_DIVISOR_INTERP - Start at gradient * v1, interpolated via
1073 * @li ECORE_POS_MAP_BOUNCE - Start at 0.0 then "drop" like a ball bouncing to
1074 * the ground at 1.0, and bounce v2 times, with decay factor of v1
1075 * @li ECORE_POS_MAP_SPRING - Start at 0.0 then "wobble" like a spring rest
1076 * position 1.0, and wobble v2 times, with decay factor of v1
1077 * @note When not listed v1 and v2 have no effect.
1079 * @image html ecore-pos-map.png
1080 * @image latex ecore-pos-map.eps width=\textwidth
1082 * One way to use this would be:
1084 * double pos; // input position in a timeline from 0.0 to 1.0
1085 * double out; // output position after mapping
1086 * int x1, y1, x2, y2; // x1 & y1 are start position, x2 & y2 are end position
1087 * int x, y; // x & y are the calculated position
1089 * out = ecore_animator_pos_map(pos, ECORE_POS_MAP_BOUNCE, 1.8, 7);
1090 * x = (x1 * out) + (x2 * (1.0 - out));
1091 * y = (y1 * out) + (y2 * (1.0 - out));
1092 * move_my_object_to(myobject, x, y);
1094 * This will make an animaton that bounces 7 each times diminishing by a
1097 * @see _Ecore_Pos_Map
1101 EAPI double ecore_animator_pos_map(double pos, Ecore_Pos_Map map, double v1, double v2);
1103 * @brief Set the source of animator ticks for the mainloop
1105 * @param source The source of animator ticks to use
1107 * This sets the source of animator ticks. When an animator is active the
1108 * mainloop will "tick" over frame by frame calling all animators that are
1109 * registered until none are. The mainloop will tick at a given rate based
1110 * on the animator source. The default source is the system clock timer
1111 * source - ECORE_ANIMATOR_SOURCE_TIMER. This source uses the system clock
1112 * to tick over every N seconds (specified by ecore_animator_frametime_set(),
1113 * with the default being 1/30th of a second unless set otherwise). You can
1114 * set a custom tick source by setting the source to
1115 * ECORE_ANIMATOR_SOURCE_CUSTOM and then drive it yourself based on some input
1116 * tick source (like another application via ipc, some vertical blanking
1117 * interrupt interrupt etc.) using
1118 * ecore_animator_custom_source_tick_begin_callback_set() and
1119 * ecore_animator_custom_source_tick_end_callback_set() to set the functions
1120 * that will be called to start and stop the ticking source, which when it
1121 * gets a "tick" should call ecore_animator_custom_tick() to make the "tick" over 1
1124 EAPI void ecore_animator_source_set(Ecore_Animator_Source source);
1126 * @brief Get the animator source currently set.
1128 * @return The current animator source
1130 * This gets the current animator source.
1132 * @see ecore_animator_source_set()
1134 EAPI Ecore_Animator_Source ecore_animator_source_get(void);
1136 * @brief Set the function that begins a custom animator tick source
1138 * @param func The function to call when ticking is to begin
1139 * @param data The data passed to the tick begin function as its parameter
1141 * The Ecore Animator infrastructure handles tracking if animators are needed
1142 * or not and which ones need to be called and when, but when the tick source
1143 * is custom, you have to provide a tick source by calling
1144 * ecore_animator_custom_tick() to indicate a frame tick happened. In order
1145 * to allow the source of ticks to be dynamically enabled or disabled as
1146 * needed, the @p func when set is called to enable the tick source to
1147 * produce tick events that call ecore_animator_custom_tick(). If @p func
1148 * is NULL then no function is called to begin custom ticking.
1150 * @see ecore_animator_source_set()
1151 * @see ecore_animator_custom_source_tick_end_callback_set()
1152 * @see ecore_animator_custom_tick()
1154 EAPI void ecore_animator_custom_source_tick_begin_callback_set(Ecore_Cb func, const void *data);
1156 * @brief Set the function that ends a custom animator tick source
1158 * @param func The function to call when ticking is to end
1159 * @param data The data passed to the tick end function as its parameter
1161 * This function is a matching pair to the function set by
1162 * ecore_animator_custom_source_tick_begin_callback_set() and is called
1163 * when ticking is to stop. If @p func is NULL then no function will be
1164 * called to stop ticking. For more information please see
1165 * ecore_animator_custom_source_tick_begin_callback_set().
1167 * @see ecore_animator_source_set()
1168 * @see ecore_animator_custom_source_tick_begin_callback_set()
1169 * @see ecore_animator_custom_tick()
1171 EAPI void ecore_animator_custom_source_tick_end_callback_set(Ecore_Cb func, const void *data);
1173 * @brief Trigger a custom animator tick
1175 * When animator source is set to ECORE_ANIMATOR_SOURCE_CUSTOM, then calling
1176 * this function triggers a run of all animators currently registered with
1177 * Ecore as this indicates a "frame tick" happened. This will do nothing if
1178 * the animator source(set by ecore_animator_source_set()) is not set to
1179 * ECORE_ANIMATOR_SOURCE_CUSTOM.
1181 * @see ecore_animator_source_set()
1182 * @see ecore_animator_custom_source_tick_begin_callback_set
1183 * @see ecore_animator_custom_source_tick_end_callback_set()()
1185 EAPI void ecore_animator_custom_tick(void);
1192 * @defgroup Ecore_Time_Group Ecore Time functions
1194 * Functions that deal with time. These functions include those
1195 * that simply retrieve it in a given format, and those that create
1196 * events based on it.
1198 * The timer allows callbacks to be called at specific intervals.
1200 * Examples with functions that deal with time:
1201 * @li @ref ecore_time_functions_example_c
1202 * @li @ref ecore_timer_example_c
1204 * @ingroup Ecore_Main_Loop_Group
1209 typedef struct _Ecore_Timer Ecore_Timer; /**< A handle for timers */
1211 EAPI double ecore_time_get(void);
1212 EAPI double ecore_time_unix_get(void);
1213 EAPI double ecore_loop_time_get(void);
1215 EAPI Ecore_Timer *ecore_timer_add(double in, Ecore_Task_Cb func, const void *data);
1216 EAPI Ecore_Timer *ecore_timer_loop_add(double in, Ecore_Task_Cb func, const void *data);
1217 EAPI void *ecore_timer_del(Ecore_Timer *timer);
1218 EAPI void ecore_timer_interval_set(Ecore_Timer *timer, double in);
1219 EAPI double ecore_timer_interval_get(Ecore_Timer *timer);
1220 EAPI void ecore_timer_freeze(Ecore_Timer *timer);
1221 EAPI void ecore_timer_thaw(Ecore_Timer *timer);
1222 EAPI void ecore_timer_delay(Ecore_Timer *timer, double add);
1223 EAPI double ecore_timer_pending_get(Ecore_Timer *timer);
1224 EAPI double ecore_timer_precision_get(void);
1225 EAPI void ecore_timer_precision_set(double precision);
1226 EAPI char *ecore_timer_dump(void);
1233 * @defgroup Ecore_Idle_Group Ecore Idle functions
1235 * Callbacks that are called when the program enters or exits an
1238 * The ecore main loop enters an idle state when it is waiting for
1239 * timers to time out, data to come in on a file descriptor or any
1240 * other event to occur. You can set callbacks to be called when
1241 * the main loop enters an idle state, during an idle state or just
1242 * after the program wakes up.
1244 * Enterer callbacks are good for updating your program's state, if
1245 * it has a state engine. Once all of the enterer handlers are
1246 * called, the program will enter a "sleeping" state.
1248 * Idler callbacks are called when the main loop has called all
1249 * enterer handlers. They are useful for interfaces that require
1250 * polling and timers would be too slow to use.
1252 * If no idler callbacks are specified, then the process literally
1253 * goes to sleep. Otherwise, the idler callbacks are called
1254 * continuously while the loop is "idle", using as much CPU as is
1255 * available to the process.
1257 * Exiter callbacks are called when the main loop wakes up from an
1260 * @note Idle state doesn't mean that the @b program is idle, but
1261 * that the <b>main loop</b> is idle. It doesn't have any timers,
1262 * events, fd handlers or anything else to process (which in most
1263 * <em>event driven</em> programs also means that the @b program is
1264 * idle too, but it's not a rule). The program itself may be doing
1265 * a lot of processing in the idler, or in another thread, for
1268 * Example with functions that deal with idle state:
1270 * @li @ref ecore_idler_example_c
1272 * @ingroup Ecore_Main_Loop_Group
1277 typedef struct _Ecore_Idler Ecore_Idler; /**< A handle for idlers */
1278 typedef struct _Ecore_Idle_Enterer Ecore_Idle_Enterer; /**< A handle for idle enterers */
1279 typedef struct _Ecore_Idle_Exiter Ecore_Idle_Exiter; /**< A handle for idle exiters */
1282 * Add an idler handler.
1283 * @param func The function to call when idling.
1284 * @param data The data to be passed to this @p func call.
1285 * @return A idler handle if successfully added. NULL otherwise.
1287 * Add an idler handle to the event loop, returning a handle on
1288 * success and NULL otherwise. The function @p func will be called
1289 * repeatedly while no other events are ready to be processed, as
1290 * long as it returns 1 (or ECORE_CALLBACK_RENEW). A return of 0
1291 * (or ECORE_CALLBACK_CANCEL) deletes the idler.
1293 * Idlers are useful for progressively prossessing data without blocking.
1295 EAPI Ecore_Idler *ecore_idler_add(Ecore_Task_Cb func, const void *data);
1298 * Delete an idler callback from the list to be executed.
1299 * @param idler The handle of the idler callback to delete
1300 * @return The data pointer passed to the idler callback on success. NULL
1303 EAPI void *ecore_idler_del(Ecore_Idler *idler);
1305 EAPI Ecore_Idle_Enterer *ecore_idle_enterer_add(Ecore_Task_Cb func, const void *data);
1306 EAPI Ecore_Idle_Enterer *ecore_idle_enterer_before_add(Ecore_Task_Cb func, const void *data);
1307 EAPI void *ecore_idle_enterer_del(Ecore_Idle_Enterer *idle_enterer);
1309 EAPI Ecore_Idle_Exiter *ecore_idle_exiter_add(Ecore_Task_Cb func, const void *data);
1310 EAPI void *ecore_idle_exiter_del(Ecore_Idle_Exiter *idle_exiter);
1317 * @defgroup Ecore_Thread_Group Ecore Thread functions
1319 * Facilities to run heavy tasks in different threads to avoid blocking
1322 * The EFL is, for the most part, not thread safe. This means that if you
1323 * have some task running in another thread and you have, for example, an
1324 * Evas object to show the status progress of this task, you cannot update
1325 * the object from within the thread. This can only be done from the main
1326 * thread, the one running the main loop. This problem can be solved
1327 * by running a thread that sends messages to the main one using an
1328 * @ref Ecore_Pipe_Group "Ecore_Pipe", but when you need to handle other
1329 * things like cancelling the thread, your code grows in coplexity and gets
1330 * much harder to maintain.
1332 * Ecore Thread is here to solve that problem. It is @b not a simple wrapper
1333 * around standard POSIX threads (or the equivalent in other systems) and
1334 * it's not meant to be used to run parallel tasks throughout the entire
1335 * duration of the program, especially when these tasks are performance
1336 * critical, as Ecore manages these tasks using a pool of threads based on
1337 * system configuration.
1339 * What Ecore Thread does, is make it a lot easier to dispatch a worker
1340 * function to perform some heavy task and then get the result once it
1341 * completes, without blocking the application's UI. In addition, cancelling
1342 * and rescheduling comes practically for free and the developer needs not
1343 * worry about how many threads are launched, since Ecore will schedule
1344 * them according to the number of processors the system has and maximum
1345 * amount of concurrent threads set for the application.
1347 * At the system level, Ecore will start a new thread on an as-needed basis
1348 * until the maximum set is reached. When no more threads can be launched,
1349 * new worker functions will be queued in a waiting list until a thread
1350 * becomes available. This way, system threads will be shared throughout
1351 * different worker functions, but running only one at a time. At the same
1352 * time, a worker function that is rescheduled may be run on a different
1353 * thread the next time.
1355 * The ::Ecore_Thread handler has two meanings, depending on what context
1356 * it is on. The one returned when starting a worker with any of the
1357 * functions ecore_thread_run() or ecore_thread_feedback_run() is an
1358 * identifier of that specific instance of the function and can be used from
1359 * the main loop with the ecore_thread_cancel() and ecore_thread_check()
1360 * functions. This handler must not be shared with the worker function
1361 * function running in the thread. This same handler will be the one received
1362 * on the @c end, @c cancel and @c feedback callbacks.
1364 * The worker function, that's the one running in the thread, also receives
1365 * an ::Ecore_Thread handler that can be used with ecore_thread_cancel() and
1366 * ecore_thread_check(), sharing the flag with the main loop. But this
1367 * handler is also associated with the thread where the function is running.
1368 * This has strong implications when working with thread local data.
1370 * There are two kinds of worker threads Ecore handles: simple, or short,
1371 * workers and feedback workers.
1373 * The first kind is for simple functions that perform a
1374 * usually small but time consuming task. Ecore will run this function in
1375 * a thread as soon as one becomes available and notify the calling user of
1376 * its completion once the task is done.
1378 * The following image shows the flow of a program running four tasks on
1379 * a pool of two threads.
1381 * @image html ecore_thread.png
1382 * @image rtf ecore_thread.png
1383 * @image latex ecore_thread.eps width=\textwidth
1385 * For larger tasks that may require continuous communication with the main
1386 * program, the feedback workers provide the same functionality plus a way
1387 * for the function running in the thread to send messages to the main
1390 * The next diagram omits some details shown in the previous one regarding
1391 * how threads are spawned and tasks are queued, but illustrates how feedback
1392 * jobs communicate with the main loop and the special case of threads
1393 * running out of pool.
1395 * @image html ecore_thread_feedback.png
1396 * @image rtf ecore_thread_feedback.png
1397 * @image latex ecore_thread_feedback.eps width=\textwidth
1399 * See an overview example in @ref ecore_thread_example_c.
1401 * @ingroup Ecore_Main_Loop_Group
1406 typedef struct _Ecore_Thread Ecore_Thread; /**< A handle for threaded jobs */
1409 * @typedef Ecore_Thread_Cb Ecore_Thread_Cb
1410 * A callback used by Ecore_Thread helper.
1412 typedef void (*Ecore_Thread_Cb) (void *data, Ecore_Thread *thread);
1414 * @typedef Ecore_Thread_Notify_Cb Ecore_Thread_Notify_Cb
1415 * A callback used by the main loop to receive data sent by an
1416 * @ref Ecore_Thread_Group.
1418 typedef void (*Ecore_Thread_Notify_Cb) (void *data, Ecore_Thread *thread, void *msg_data);
1421 * Schedule a task to run in a parallel thread to avoid locking the main loop
1423 * @param func_blocking The function that should run in another thread.
1424 * @param func_end Function to call from main loop when @p func_blocking
1425 * completes its task successfully (may be NULL)
1426 * @param func_cancel Function to call from main loop if the thread running
1427 * @p func_blocking is cancelled or fails to start (may be NULL)
1428 * @param data User context data to pass to all callbacks.
1429 * @return A new thread handler, or NULL on failure
1431 * This function will try to create a new thread to run @p func_blocking in,
1432 * or if the maximum number of concurrent threads has been reached, will
1433 * add it to the pending list, where it will wait until a thread becomes
1434 * available. The return value will be an ::Ecore_Thread handle that can
1435 * be used to cancel the thread before its completion.
1437 * @note This function should always return immediately, but in the rare
1438 * case that Ecore is built with no thread support, @p func_blocking will
1439 * be called here, actually blocking the main loop.
1441 * Once a thread becomes available, @p func_blocking will be run in it until
1442 * it finishes, then @p func_end is called from the thread containing the
1443 * main loop to inform the user of its completion. While in @p func_blocking,
1444 * no functions from the EFL can be used, except for those from Eina that are
1445 * marked to be thread-safe. Even for the latter, caution needs to be taken
1446 * if the data is shared across several threads.
1448 * @p func_end will be called from the main thread when @p func_blocking ends,
1449 * so here it's safe to use anything from the EFL freely.
1451 * The thread can also be cancelled before its completion calling
1452 * ecore_thread_cancel(), either from the main thread or @p func_blocking.
1453 * In this case, @p func_cancel will be called, also from the main thread
1454 * to inform of this happening. If the thread could not be created, this
1455 * function will be called and it's @c thread parameter will be NULL. It's
1456 * also safe to call any EFL function here, as it will be running in the
1459 * Inside @p func_blocking, it's possible to call ecore_thread_reschedule()
1460 * to tell Ecore that this function should be called again.
1462 * Be aware that no assumptions can be made about the order in which the
1463 * @p func_end callbacks for each task will be called. Once the function is
1464 * running in a different thread, it's the OS that will handle its running
1465 * schedule, and different functions may take longer to finish than others.
1466 * Also remember that just starting several tasks together doesn't mean they
1467 * will be running at the same time. Ecore will schedule them based on the
1468 * number of threads available for the particular system it's running in,
1469 * so some of the jobs started may be waiting until another one finishes
1470 * before it can execute its own @p func_blocking.
1472 * @see ecore_thread_feedback_run()
1473 * @see ecore_thread_cancel()
1474 * @see ecore_thread_reschedule()
1475 * @see ecore_thread_max_set()
1477 EAPI Ecore_Thread *ecore_thread_run(Ecore_Thread_Cb func_blocking,
1478 Ecore_Thread_Cb func_end,
1479 Ecore_Thread_Cb func_cancel,
1482 * Launch a thread to run a task than can talk back to the main thread
1484 * @param func_heavy The function that should run in another thread.
1485 * @param func_notify Function that receives the data sent from the thread
1486 * @param func_end Function to call from main loop when @p func_heavy
1487 * completes its task successfully
1488 * @param func_cancel Function to call from main loop if the thread running
1489 * @p func_heavy is cancelled or fails to start
1490 * @param data User context data to pass to all callback.
1491 * @param try_no_queue If you want to run outside of the thread pool.
1492 * @return A new thread handler, or NULL on failure
1494 * See ecore_thread_run() for a general description of this function.
1496 * The difference with the above is that ecore_thread_run() is meant for
1497 * tasks that don't need to communicate anything until they finish, while
1498 * this function is provided with a new callback, @p func_notify, that will
1499 * be called from the main thread for every message sent from @p func_heavy
1500 * with ecore_thread_feedback().
1502 * Like with ecore_thread_run(), a new thread will be launched to run
1503 * @p func_heavy unless the maximum number of simultaneous threadas has been
1504 * reached, in which case the function will be scheduled to run whenever a
1505 * running task ends and a thread becomes free. But if @p try_no_queue is
1506 * set, Ecore will first try to launch a thread outside of the pool to run
1507 * the task. If it fails, it will revert to the normal behaviour of using a
1508 * thread from the pool as if @p try_no_queue had not been set.
1510 * Keep in mind that Ecore handles the thread pool based on the number of
1511 * CPUs available, but running a thread outside of the pool doesn't count for
1512 * this, so having too many of them may have drastic effects over the
1513 * program's performance.
1515 * @see ecore_thread_feedback()
1516 * @see ecore_thread_run()
1517 * @see ecore_thread_cancel()
1518 * @see ecore_thread_reschedule()
1519 * @see ecore_thread_max_set()
1521 EAPI Ecore_Thread *ecore_thread_feedback_run(Ecore_Thread_Cb func_heavy,
1522 Ecore_Thread_Notify_Cb func_notify,
1523 Ecore_Thread_Cb func_end,
1524 Ecore_Thread_Cb func_cancel,
1526 Eina_Bool try_no_queue);
1528 * Cancel a running thread.
1530 * @param thread The thread to cancel.
1531 * @return Will return EINA_TRUE if the thread has been cancelled,
1532 * EINA_FALSE if it is pending.
1534 * This function can be called both in the main loop or in the running thread.
1536 * This function cancels a running thread. If @p thread can be immediately
1537 * cancelled (it's still pending execution after creation or rescheduling),
1538 * then the @c cancel callback will be called, @p thread will be freed and
1539 * the function will return EINA_TRUE.
1541 * If the thread is already running, then this function returns EINA_FALSE
1542 * after marking the @p thread as pending cancellation. For the thread to
1543 * actually be terminated, it needs to return from the user function back
1544 * into Ecore control. This can happen in several ways:
1545 * @li The function ends and returns normally. If it hadn't been cancelled,
1546 * @c func_end would be called here, but instead @c func_cancel will happen.
1547 * @li The function returns after requesting to be rescheduled with
1548 * ecore_thread_reschedule().
1549 * @li The function is prepared to leave early by checking if
1550 * ecore_thread_check() returns EINA_TRUE.
1552 * The user function can cancel itself by calling ecore_thread_cancel(), but
1553 * it should always use the ::Ecore_Thread handle passed to it and never
1554 * share it with the main loop thread by means of shared user data or any
1557 * @p thread will be freed and should not be used again if this function
1558 * returns EINA_TRUE or after the @c func_cancel callback returns.
1560 * @see ecore_thread_check()
1562 EAPI Eina_Bool ecore_thread_cancel(Ecore_Thread *thread);
1564 * Checks if a thread is pending cancellation
1566 * @param thread The thread to test.
1567 * @return EINA_TRUE if the thread is pending cancellation,
1568 * EINA_FALSE if it is not.
1570 * This function can be called both in the main loop or in the running thread.
1572 * When ecore_thread_cancel() is called on an already running task, the
1573 * thread is marked as pending cancellation. This function returns EINA_TRUE
1574 * if this mark is set for the given @p thread and can be used from the
1575 * main loop thread to check if a still active thread has been cancelled,
1576 * or from the user function running in the thread to check if it should
1577 * stop doing what it's doing and return early, effectively cancelling the
1580 * @see ecore_thread_cancel()
1582 EAPI Eina_Bool ecore_thread_check(Ecore_Thread *thread);
1584 * Sends data from the worker thread to the main loop
1586 * @param thread The current ::Ecore_Thread context to send data from
1587 * @param msg_data Data to be transmitted to the main loop
1588 * @return EINA_TRUE if @p msg_data was successfully sent to main loop,
1589 * EINA_FALSE if anything goes wrong.
1591 * You should use this function only in the @c func_heavy call.
1593 * Only the address to @p msg_data will be sent and once this function
1594 * returns EINA_TRUE, the job running in the thread should never touch the
1595 * contents of it again. The data sent should be malloc()'ed or something
1596 * similar, as long as it's not memory local to the thread that risks being
1597 * overwritten or deleted once it goes out of scope or the thread finishes.
1599 * Care must be taken that @p msg_data is properly freed in the @c func_notify
1600 * callback set when creating the thread.
1602 * @see ecore_thread_feedback_run()
1604 EAPI Eina_Bool ecore_thread_feedback(Ecore_Thread *thread, const void *msg_data);
1606 * Asks for the function in the thread to be called again at a later time
1608 * @param thread The current ::Ecore_Thread context to rescheduled
1609 * @return EINA_TRUE if the task was successfully rescheduled,
1610 * EINA_FALSE if anything goes wrong.
1612 * This function should be called only from the same function represented
1615 * Calling this function will mark the thread for a reschedule, so as soon
1616 * as it returns, it will be added to the end of the list of pending tasks.
1617 * If no other tasks are waiting or there are sufficient threads available,
1618 * the rescheduled task will be launched again immediately.
1620 * This should never return EINA_FALSE, unless it was called from the wrong
1621 * thread or with the wrong arguments.
1623 * The @c func_end callback set when the thread is created will not be
1624 * called until the function in the thread returns without being rescheduled.
1625 * Similarly, if the @p thread is cancelled, the reschedule will not take
1628 EAPI Eina_Bool ecore_thread_reschedule(Ecore_Thread *thread);
1630 * Gets the number of active threads running jobs
1632 * @return Number of active threads running jobs
1634 * This returns the number of threads currently running jobs of any type
1635 * through the Ecore_Thread API.
1637 * @note Jobs started through the ecore_thread_feedback_run() function with
1638 * the @c try_no_queue parameter set to EINA_TRUE will not be accounted for
1639 * in the return of this function unless the thread creation fails and it
1640 * falls back to using one from the pool.
1642 EAPI int ecore_thread_active_get(void);
1644 * Gets the number of short jobs waiting for a thread to run
1646 * @return Number of pending threads running "short" jobs
1648 * This returns the number of tasks started with ecore_thread_run() that are
1649 * pending, waiting for a thread to become available to run them.
1651 EAPI int ecore_thread_pending_get(void);
1653 * Gets the number of feedback jobs waiting for a thread to run
1655 * @return Number of pending threads running "feedback" jobs
1657 * This returns the number of tasks started with ecore_thread_feedback_run()
1658 * that are pending, waiting for a thread to become available to run them.
1660 EAPI int ecore_thread_pending_feedback_get(void);
1662 * Gets the total number of pending jobs
1664 * @return Number of pending threads running jobs
1666 * Same as the sum of ecore_thread_pending_get() and
1667 * ecore_thread_pending_feedback_get().
1669 EAPI int ecore_thread_pending_total_get(void);
1671 * Gets the maximum number of threads that can run simultaneously
1673 * @return Max possible number of Ecore_Thread's running concurrently
1675 * This returns the maximum number of Ecore_Thread's that may be running at
1676 * the same time. If this number is reached, new jobs started by either
1677 * ecore_thread_run() or ecore_thread_feedback_run() will be added to the
1678 * respective pending queue until one of the running threads finishes its
1679 * task and becomes available to run a new one.
1681 * By default, this will be the number of available CPUs for the
1682 * running program (as returned by eina_cpu_count()), or 1 if this value
1683 * could not be fetched.
1685 * @see ecore_thread_max_set()
1686 * @see ecore_thread_max_reset()
1688 EAPI int ecore_thread_max_get(void);
1690 * Sets the maximum number of threads allowed to run simultaneously
1692 * @param num The new maximum
1694 * This sets a new value for the maximum number of concurrently running
1695 * Ecore_Thread's. It @b must an integer between 1 and (2 * @c x), where @c x
1696 * is the number for CPUs available.
1698 * @see ecore_thread_max_get()
1699 * @see ecore_thread_max_reset()
1701 EAPI void ecore_thread_max_set(int num);
1703 * Resets the maximum number of concurrently running threads to the default
1705 * This resets the value returned by ecore_thread_max_get() back to its
1708 * @see ecore_thread_max_get()
1709 * @see ecore_thread_max_set()
1711 EAPI void ecore_thread_max_reset(void);
1713 * Gets the number of threads available for running tasks
1715 * @return The number of available threads
1717 * Same as doing ecore_thread_max_get() - ecore_thread_active_get().
1719 * This function may return a negative number only in the case the user
1720 * changed the maximum number of running threads while other tasks are
1723 EAPI int ecore_thread_available_get(void);
1725 * Adds some data to a hash local to the thread
1727 * @param thread The thread context the data belongs to
1728 * @param key The name under which the data will be stored
1729 * @param value The data to add
1730 * @param cb Function to free the data when removed from the hash
1731 * @param direct If true, this will not copy the key string (like
1732 * eina_hash_direct_add())
1733 * @return EINA_TRUE on success, EINA_FALSE on failure
1735 * Ecore Thread has a mechanism to share data across several worker functions
1736 * that run on the same system thread. That is, the data is stored per
1737 * thread and for a worker function to have access to it, it must be run
1738 * by the same thread that stored the data.
1740 * When there are no more workers pending, the thread will be destroyed
1741 * along with the internal hash and any data left in it will be freed with
1742 * the @p cb function given.
1744 * This set of functions is useful to share things around several instances
1745 * of a function when that thing is costly to create and can be reused, but
1746 * may only be used by one function at a time.
1748 * For example, if you have a program doing requisitions to a database,
1749 * these requisitions can be done in threads so that waiting for the
1750 * database to respond doesn't block the UI. Each of these threads will
1751 * run a function, and each function will be dependent on a connection to
1752 * the database, which may not be able to handle more than one request at
1753 * a time so for each running function you will need one connection handle.
1754 * The options then are:
1755 * @li Each function opens a connection when it's called, does the work and
1756 * closes the connection when it finishes. This may be costly, wasting a lot
1757 * of time on resolving hostnames, negotiating permissions and allocating
1759 * @li Open the connections in the main loop and pass it to the threads
1760 * using the data pointer. Even worse, it's just as costly as before and now
1761 * it may even be kept with connections open doing nothing until a thread
1762 * becomes available to run the function.
1763 * @li Have a way to share connection handles, so that each instance of the
1764 * function can check if an available connection exists, and if it doesn't,
1765 * create one and add it to the pool. When no more connections are needed,
1766 * they are all closed.
1768 * The last option is the most efficient, but it requires a lot of work to
1769 * implement properly. Using thread local data helps to achieve the same
1770 * result while avoiding doing all the tracking work on your code. The way
1771 * to use it would be, at the worker function, to ask for the connection
1772 * with ecore_thread_local_data_find() and if it doesn't exist, then open
1773 * a new one and save it with ecore_thread_local_data_add(). Do the work and
1774 * forget about the connection handle, when everything is done the function
1775 * just ends. The next worker to run on that thread will check if a
1776 * connection exists and find that it does, so the process of opening a
1777 * new one has been spared. When no more workers exist, the thread is
1778 * destroyed and the callback used when saving the connection will be called
1781 * This function adds the data @p value to the thread data under the given
1783 * No other value in the hash may have the same @p key. If you need to
1784 * change the value under a @p key, or you don't know if one exists already,
1785 * you can use ecore_thread_local_data_set().
1787 * Neither @p key nor @p value may be NULL and @p key will be copied in the
1788 * hash, unless @p direct is set, in which case the string used should not
1789 * be freed until the data is removed from the hash.
1791 * The @p cb function will be called when the data in the hash needs to be
1792 * freed, be it because it got deleted with ecore_thread_local_data_del() or
1793 * because @p thread was terminated and the hash destroyed. This parameter
1794 * may be NULL, in which case @p value needs to be manually freed after
1795 * removing it from the hash with either ecore_thread_local_data_del() or
1796 * ecore_thread_local_data_set(), but it's very unlikely that this is what
1799 * This function, and all of the others in the @c ecore_thread_local_data
1800 * family of functions, can only be called within the worker function running
1801 * in the thread. Do not call them from the main loop or from a thread
1802 * other than the one represented by @p thread.
1804 * @see ecore_thread_local_data_set()
1805 * @see ecore_thread_local_data_find()
1806 * @see ecore_thread_local_data_del()
1808 EAPI Eina_Bool ecore_thread_local_data_add(Ecore_Thread *thread, const char *key, void *value, Eina_Free_Cb cb, Eina_Bool direct);
1810 * Sets some data in the hash local to the given thread
1812 * @param thread The thread context the data belongs to
1813 * @param key The name under which the data will be stored
1814 * @param value The data to add
1815 * @param cb Function to free the data when removed from the hash
1817 * If no data exists in the hash under the @p key, this function adds
1818 * @p value in the hash under the given @p key and returns NULL.
1819 * The key itself is copied.
1821 * If the hash already contains something under @p key, the data will be
1822 * replaced by @p value and the old value will be returned.
1824 * NULL will also be returned if either @p key or @p value are NULL, or if
1825 * an error occurred.
1827 * This function, and all of the others in the @c ecore_thread_local_data
1828 * family of functions, can only be called within the worker function running
1829 * in the thread. Do not call them from the main loop or from a thread
1830 * other than the one represented by @p thread.
1832 * @see ecore_thread_local_data_add()
1833 * @see ecore_thread_local_data_del()
1834 * @see ecore_thread_local_data_find()
1836 EAPI void *ecore_thread_local_data_set(Ecore_Thread *thread, const char *key, void *value, Eina_Free_Cb cb);
1838 * Gets data stored in the hash local to the given thread
1840 * @param thread The thread context the data belongs to
1841 * @param key The name under which the data is stored
1842 * @return The value under the given key, or NULL on error
1844 * Finds and return the data stored in the shared hash under the key @p key.
1846 * This function, and all of the others in the @c ecore_thread_local_data
1847 * family of functions, can only be called within the worker function running
1848 * in the thread. Do not call them from the main loop or from a thread
1849 * other than the one represented by @p thread.
1851 * @see ecore_thread_local_data_add()
1852 * @see ecore_thread_local_data_wait()
1854 EAPI void *ecore_thread_local_data_find(Ecore_Thread *thread, const char *key);
1856 * Deletes from the thread's hash the data corresponding to the given key
1858 * @param thread The thread context the data belongs to
1859 * @param key The name under which the data is stored
1860 * @return EINA_TRUE on success, EINA_FALSE on failure
1862 * If there's any data stored associated with @p key in the global hash,
1863 * this function will remove it from it and return EINA_TRUE. If no data
1864 * exists or an error occurs, it returns EINA_FALSE.
1866 * If the data was added to the hash with a free function, then it will
1867 * also be freed after removing it from the hash, otherwise it requires
1868 * to be manually freed by the user, which means that if no other reference
1869 * to it exists before calling this function, it will result in a memory
1872 * This function, and all of the others in the @c ecore_thread_local_data
1873 * family of functions, can only be called within the worker function running
1874 * in the thread. Do not call them from the main loop or from a thread
1875 * other than the one represented by @p thread.
1877 * @see ecore_thread_local_data_add()
1879 EAPI Eina_Bool ecore_thread_local_data_del(Ecore_Thread *thread, const char *key);
1882 * Adds some data to a hash shared by all threads
1884 * @param key The name under which the data will be stored
1885 * @param value The data to add
1886 * @param cb Function to free the data when removed from the hash
1887 * @param direct If true, this will not copy the key string (like
1888 * eina_hash_direct_add())
1889 * @return EINA_TRUE on success, EINA_FALSE on failure
1891 * Ecore Thread keeps a hash that can be used to share data across several
1892 * threads, including the main loop one, without having to manually handle
1893 * mutexes to do so safely.
1895 * This function adds the data @p value to this hash under the given @p key.
1896 * No other value in the hash may have the same @p key. If you need to
1897 * change the value under a @p key, or you don't know if one exists already,
1898 * you can use ecore_thread_global_data_set().
1900 * Neither @p key nor @p value may be NULL and @p key will be copied in the
1901 * hash, unless @p direct is set, in which case the string used should not
1902 * be freed until the data is removed from the hash.
1904 * The @p cb function will be called when the data in the hash needs to be
1905 * freed, be it because it got deleted with ecore_thread_global_data_del() or
1906 * because Ecore Thread was shut down and the hash destroyed. This parameter
1907 * may be NULL, in which case @p value needs to be manually freed after
1908 * removing it from the hash with either ecore_thread_global_data_del() or
1909 * ecore_thread_global_data_set().
1911 * Manually freeing any data that was added to the hash with a @p cb function
1912 * is likely to produce a segmentation fault, or any other strange
1913 * happenings, later on in the program.
1915 * @see ecore_thread_global_data_del()
1916 * @see ecore_thread_global_data_set()
1917 * @see ecore_thread_global_data_find()
1919 EAPI Eina_Bool ecore_thread_global_data_add(const char *key, void *value, Eina_Free_Cb cb, Eina_Bool direct);
1921 * Sets some data in the hash shared by all threads
1923 * @param key The name under which the data will be stored
1924 * @param value The data to add
1925 * @param cb Function to free the data when removed from the hash
1927 * If no data exists in the hash under the @p key, this function adds
1928 * @p value in the hash under the given @p key and returns NULL.
1929 * The key itself is copied.
1931 * If the hash already contains something under @p key, the data will be
1932 * replaced by @p value and the old value will be returned.
1934 * NULL will also be returned if either @p key or @p value are NULL, or if
1935 * an error occurred.
1937 * @see ecore_thread_global_data_add()
1938 * @see ecore_thread_global_data_del()
1939 * @see ecore_thread_global_data_find()
1941 EAPI void *ecore_thread_global_data_set(const char *key, void *value, Eina_Free_Cb cb);
1943 * Gets data stored in the hash shared by all threads
1945 * @param key The name under which the data is stored
1946 * @return The value under the given key, or NULL on error
1948 * Finds and return the data stored in the shared hash under the key @p key.
1950 * Keep in mind that the data returned may be used by more than one thread
1951 * at the same time and no reference counting is done on it by Ecore.
1952 * Freeing the data or modifying its contents may require additional
1953 * precautions to be considered, depending on the application's design.
1955 * @see ecore_thread_global_data_add()
1956 * @see ecore_thread_global_data_wait()
1958 EAPI void *ecore_thread_global_data_find(const char *key);
1960 * Deletes from the shared hash the data corresponding to the given key
1962 * @param key The name under which the data is stored
1963 * @return EINA_TRUE on success, EINA_FALSE on failure
1965 * If there's any data stored associated with @p key in the global hash,
1966 * this function will remove it from it and return EINA_TRUE. If no data
1967 * exists or an error occurs, it returns EINA_FALSE.
1969 * If the data was added to the hash with a free function, then it will
1970 * also be freed after removing it from the hash, otherwise it requires
1971 * to be manually freed by the user, which means that if no other reference
1972 * to it exists before calling this function, it will result in a memory
1975 * Note, also, that freeing data that other threads may be using will result
1976 * in a crash, so appropriate care must be taken by the application when
1977 * that possibility exists.
1979 * @see ecore_thread_global_data_add()
1981 EAPI Eina_Bool ecore_thread_global_data_del(const char *key);
1983 * Gets data stored in the shared hash, or wait for it if it doesn't exist
1985 * @param key The name under which the data is stored
1986 * @param seconds The amount of time in seconds to wait for the data.
1987 * @return The value under the given key, or NULL on error
1989 * Finds and return the data stored in the shared hash under the key @p key.
1991 * If there's nothing in the hash under the given @p key, the function
1992 * will block and wait up to @p seconds seconds for some other thread to
1993 * add it with either ecore_thread_global_data_add() or
1994 * ecore_thread_global_data_set(). If after waiting there's still no data
1995 * to get, NULL will be returned.
1997 * If @p seconds is 0, then no waiting will happen and this function works
1998 * like ecore_thread_global_data_find(). If @p seconds is less than 0, then
1999 * the function will wait indefinitely.
2001 * Keep in mind that the data returned may be used by more than one thread
2002 * at the same time and no reference counting is done on it by Ecore.
2003 * Freeing the data or modifying its contents may require additional
2004 * precautions to be considered, depending on the application's design.
2006 * @see ecore_thread_global_data_add()
2007 * @see ecore_thread_global_data_find()
2009 EAPI void *ecore_thread_global_data_wait(const char *key, double seconds);
2016 * @defgroup Ecore_Pipe_Group Pipe wrapper
2018 * These functions wrap the pipe / write / read functions to easily
2019 * integrate its use into ecore's main loop.
2021 * The ecore_pipe_add() function creates file descriptors (sockets
2022 * on Windows) and attach a handle to the ecore main loop. That
2023 * handle is called when data is read in the pipe. To write data in
2024 * the pipe, just call ecore_pipe_write(). When you are done, just
2025 * call ecore_pipe_del().
2027 * For examples see here:
2028 * @li @ref tutorial_ecore_pipe_gstreamer_example
2029 * @li @ref tutorial_ecore_pipe_simple_example
2031 * @ingroup Ecore_Main_Loop_Group
2036 typedef struct _Ecore_Pipe Ecore_Pipe; /**< A handle for pipes */
2039 * @typedef Ecore_Pipe_Cb Ecore_Pipe_Cb
2040 * The callback that data written to the pipe is sent to.
2042 typedef void (*Ecore_Pipe_Cb) (void *data, void *buffer, unsigned int nbyte);
2044 EAPI Ecore_Pipe *ecore_pipe_add(Ecore_Pipe_Cb handler, const void *data);
2045 EAPI void *ecore_pipe_del(Ecore_Pipe *p);
2046 EAPI Eina_Bool ecore_pipe_write(Ecore_Pipe *p, const void *buffer, unsigned int nbytes);
2047 EAPI void ecore_pipe_write_close(Ecore_Pipe *p);
2048 EAPI void ecore_pipe_read_close(Ecore_Pipe *p);
2049 EAPI void ecore_pipe_thaw(Ecore_Pipe *p);
2050 EAPI void ecore_pipe_freeze(Ecore_Pipe *p);
2051 EAPI int ecore_pipe_wait(Ecore_Pipe *p, int message_count, double wait);
2058 * @defgroup Ecore_Job_Group Ecore Job functions
2060 * You can queue jobs that are to be done by the main loop when the
2061 * current event is dealt with.
2063 * Jobs are processed by the main loop similarly to events. They
2064 * also will be executed in the order in which they were added.
2066 * A good use for them is when you don't want to execute an action
2067 * immeditately, but want to give the control back to the main loop
2068 * so that it will call your job callback when jobs start being
2069 * processed (and if there are other jobs added before yours, they
2070 * will be processed first). This also gives the chance to other
2071 * actions in your program to cancel the job before it is started.
2073 * Examples of using @ref Ecore_Job:
2074 * @li @ref ecore_job_example_c
2076 * @ingroup Ecore_Main_Loop_Group
2081 typedef struct _Ecore_Job Ecore_Job; /**< A job handle */
2083 EAPI Ecore_Job *ecore_job_add(Ecore_Cb func, const void *data);
2084 EAPI void *ecore_job_del(Ecore_Job *job);
2091 * @defgroup Ecore_Application_Group Ecore Application functions
2096 EAPI void ecore_app_args_set(int argc, const char **argv);
2097 EAPI void ecore_app_args_get(int *argc, char ***argv);
2098 EAPI void ecore_app_restart(void);
2105 * @defgroup Ecore_Throttle_Group Ecore Throttle functions
2107 * @ingroup Ecore_Main_Loop_Group
2112 EAPI void ecore_throttle_adjust(double amount );
2113 EAPI double ecore_throttle_get(void);