Tizen Native API
Ecore Main Loop

This group discusses functions that are acting on Ecore's main loop itself or on events and infrastructure directly linked to it. Most programs only need to start and end the main loop, the rest of the function discussed here is meant to be used in special situations, and with great care.

For details on the usage of ecore's main loop and how it interacts with other ecore facilities see: The Ecore Main Loop.

Functions

Eina_Bool ecore_fork_reset_callback_add (Ecore_Cb func, const void *data)
 Adds a function to be called by ecore_fork_reset().
Eina_Bool ecore_fork_reset_callback_del (Ecore_Cb func, const void *data)
 Removes the specified callback.
void ecore_fork_reset (void)
 Resets the ecore's internal state after a fork.
void ecore_main_loop_iterate (void)
 Runs a single iteration of the main loop to process everything on the queue.
void ecore_main_loop_select_func_set (Ecore_Select_Function func)
 Sets the function to use when monitoring multiple file descriptors, and waiting until one of more of the file descriptors before ready for some class of I/O operation.
Ecore_Select_Function ecore_main_loop_select_func_get (void)
 Gets the select function set by ecore_select_func_set(), or the native select function if none was set.
Eina_Bool ecore_main_loop_glib_integrate (void)
 Request ecore to integrate GLib's main loop.
void ecore_main_loop_glib_always_integrate_disable (void)
 Disable always integrating glib.
void ecore_main_loop_begin (void)
 Runs the application main loop.
void ecore_main_loop_quit (void)
 Quits the main loop once all the events currently on the queue have been processed.
void ecore_main_loop_thread_safe_call_async (Ecore_Cb callback, void *data)
 Called asynchronously in the main loop.
void * ecore_main_loop_thread_safe_call_sync (Ecore_Data_Cb callback, void *data)
 Called synchronously in the main loop.
int ecore_thread_main_loop_begin (void)
 Suspends the main loop in the know state.
int ecore_thread_main_loop_end (void)
 Unlocks the main loop.

Typedefs

typedef Eina_Bool(* Ecore_Task_Cb )(void *data)
 The boolean type for a callback that is run for a task (timer, idler, poller, animator, and so on).
typedef void(* Ecore_Cb )(void *data)
 Called as a hook when a certain point in the execution is reached.
typedef void *(* Ecore_Data_Cb )(void *data)
 Called to return data to the main function.
typedef int(* Ecore_Select_Function )(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout)
 The integer type for a function that can be used to replace select() in the main loop.

Defines

#define ECORE_CALLBACK_CANCEL   EINA_FALSE
#define ECORE_CALLBACK_RENEW   EINA_TRUE
#define ECORE_CALLBACK_PASS_ON   EINA_TRUE
#define ECORE_CALLBACK_DONE   EINA_FALSE

Define Documentation

Return value to remove a callback

Return value to stop event handling

Return value to pass an event to the next handler

Return value to keep a callback


Function Documentation

void ecore_fork_reset ( void  )

Resets the ecore's internal state after a fork.

Since (EFL) :
1.7
Since :
2.3.1
Remarks:
Ecore maintains the internal data that can be affected by the fork() system call, which creates a duplicate of the current process. This also duplicates file descriptors, which is problematic as these file descriptors still point to their original sources. This function makes ecore's reset internal state (e.g. pipes used for signalling between threads) so they function correctly afterwards.
It is highly suggested that you call this function after any fork() system call inside the child process. If you intend to use ecore features after this point and not call exec() family functions. Not doing so causes a possible misbehaviour.
Eina_Bool ecore_fork_reset_callback_add ( Ecore_Cb  func,
const void *  data 
)

Adds a function to be called by ecore_fork_reset().

This queues func to be called (and passes data as its argument) when ecore_fork_reset() is called. This allows other libraries and subsystems to also reset their internal state after a fork.

Parameters:
[in]funcThe function to be called
[in]dataA data pointer to pass to the called function func
Returns:
EINA_TRUE if succeed, otherwise EINA_FALSE.
Since (EFL) :
1.7
Since :
2.3.1
Eina_Bool ecore_fork_reset_callback_del ( Ecore_Cb  func,
const void *  data 
)

Removes the specified callback.

This deletes the callback added by ecore_fork_reset_callback_add() using the function and data pointer to specify which callback to remove.

Parameters:
[in]funcThe function to be called
[in]dataA data pointer to pass to the called function func
Returns:
EINA_TRUE if succeed, otherwise EINA_FALSE.
Since (EFL) :
1.7
Since :
2.3.1
void ecore_main_loop_begin ( void  )

Runs the application main loop.

This function will not return until ecore_main_loop_quit is called. It will check for expired timers, idlers, file descriptors being watched by fd handlers, etc. Once everything is done, before entering again on idle state, any callback set as Idle_Enterer will be called.

Remarks:
Each main loop iteration is done by calling ecore_main_loop_iterate() internally.
The polling (select) function used can be changed with ecore_main_loop_select_func_set().
The function used to check for file descriptors, events, and that has a timeout for the timers can be changed using ecore_main_loop_select_func_set().
Since :
2.3.1

Disable always integrating glib.

Remarks:
If ecore is compiled with --with-glib=always (to always call ecore_main_loop_glib_integrate()), This is for apps that explicitly do not want this to happen for whatever reasons they may have.
Since :
2.3.1

Request ecore to integrate GLib's main loop.

This will add a small overhead during every main loop interaction by checking glib's default main context (used by its main loop). If it have events to be checked (timers, file descriptors or idlers), then these will be polled alongside with Ecore's own events, then dispatched before Ecore's. This is done by calling ecore_main_loop_select_func_set().

Remarks:
This will cooperate with previously set ecore_main_loop_select_func_set() by calling the old function. Similarly, if you want to override ecore_main_loop_select_func_set() after main loop is integrated, call the new select function set by this call (get it by calling ecore_main_loop_select_func_get() right after ecore_main_loop_glib_integrate()).
This is useful to use GMainLoop libraries, like GTK, GUPnP, LibSoup, GConf and more. Adobe Flash plugin and other plugins systems depend on this as well.
Once initialized/integrated, it will be valid until Ecore is completely shut down.
This is only available if Ecore was compiled with GLib support.
You don't need to call this function if Ecore was compiled with --with-glib=always.
Returns:
EINA_TRUE on success of EINA_FALSE if it failed, likely no GLib support in Ecore.
Since :
2.3.1
void ecore_main_loop_iterate ( void  )

Runs a single iteration of the main loop to process everything on the queue.

It does everything that is already done inside an Ecore main loop, like checking for expired timers, idlers, etc. But it will do it only once and return, instead of keep watching for new events.

Remarks:
DO NOT use this function unless you are the person God comes to ask for advice when He has trouble managing the Universe.
Since :
2.3.1
void ecore_main_loop_quit ( void  )

Quits the main loop once all the events currently on the queue have been processed.

This function returns immediately, but will mark the ecore_main_loop_begin() function to return at the end of the current main loop iteration.

Since :
2.3.1

Gets the select function set by ecore_select_func_set(), or the native select function if none was set.

Returns:
The select function
See also:
ecore_main_loop_select_func_get()
Since :
2.3.1

Sets the function to use when monitoring multiple file descriptors, and waiting until one of more of the file descriptors before ready for some class of I/O operation.

Remarks:
This function will be used instead of the system call select and could possible be used to integrate the Ecore event loop with an external event loop.
you don't know how to use, don't even try to use it.
Parameters:
funcThe function to be used.
See also:
ecore_main_loop_select_func_get()
Since :
2.3.1
void ecore_main_loop_thread_safe_call_async ( Ecore_Cb  callback,
void *  data 
)

Called asynchronously in the main loop.

Since (EFL) :
1.1.0
Remarks:
For all calls that need to happen in the main loop (most EFL functions do), this helper function provides the infrastructure needed to do it safely by avoiding a dead lock, race condition, and by properly waking up the main loop.
Remember that after the function call, you should never touch the data in the thread again, it is owned by the main loop and your callback should take care of freeing it, if necessary.
Parameters:
callbackThe callback to call in the main loop
dataThe data to give to that call
Since :
2.3.1
void* ecore_main_loop_thread_safe_call_sync ( Ecore_Data_Cb  callback,
void *  data 
)

Called synchronously in the main loop.

Since (EFL) :
1.1.0
Remarks:
For all calls that need to happen in the main loop (most EFL functions do), this helper function provides the infrastructure needed to do it safely by avoiding a dead lock, race condition, and by properly waking up the main loop.
Remember that this function blocks until the callback is executed in the main loop. It can take time and you have no guarantee about the timeline.
Parameters:
callbackThe callback to call in the main loop
dataThe data to give to that call
Returns:
The value returned by the callback in the main loop
Since :
2.3.1

Suspends the main loop in the know state.

This function suspends the main loop in the know state. This lets you use any EFL call that you want after it returns. Be careful, the main loop is blocked until you call ecore_thread_main_loop_end(). This is the only way to achieve pseudo thread safety.

Since (EFL) :
1.1.0
Remarks:
Notice that till the main loop is blocked, the thread is blocked and there is no way around that.
We still advise you, if possible, to use ecore_main_loop_thread_safe_call_async() as it does not block the thread or the main loop.
Returns:
The number of times ecore_thread_main_loop_begin() has been called in this thread, if the main loop is suspended correctly
If not, it returns -1.
Since :
2.3.1

Unlocks the main loop.

Since (EFL) :
1.1.0
Remarks:
After a call to ecore_thread_main_loop_begin(), you need to absolutely call ecore_thread_main_loop_end(), or your application stays frozen.
Returns:
The number of times ecore_thread_main_loop_end() needs to be called before the main loop is unlocked again
-1 is retured if you are trying to unlock when there aren't enough calls to ecore_thread_main_loop_begin().
Since :
2.3.1