diff --git a/legacy/ecore/src/lib/ecore/Ecore.h b/legacy/ecore/src/lib/ecore/Ecore.h index 0a1969d78e..84cd6c5161 100644 --- a/legacy/ecore/src/lib/ecore/Ecore.h +++ b/legacy/ecore/src/lib/ecore/Ecore.h @@ -278,6 +278,10 @@ extern "C" { EAPI void *ecore_idle_exiter_del(Ecore_Idle_Exiter *idle_exiter); EAPI void ecore_main_loop_iterate(void); + + EAPI void ecore_main_loop_select_func_set(int (*func)(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout)); + EAPI void *ecore_main_loop_select_func_get(void); + EAPI void ecore_main_loop_begin(void); EAPI void ecore_main_loop_quit(void); EAPI Ecore_Fd_Handler *ecore_main_fd_handler_add(int fd, Ecore_Fd_Handler_Flags flags, int (*func) (void *data, Ecore_Fd_Handler *fd_handler), const void *data, int (*buf_func) (void *buf_data, Ecore_Fd_Handler *fd_handler), const void *buf_data); diff --git a/legacy/ecore/src/lib/ecore/ecore_main.c b/legacy/ecore/src/lib/ecore/ecore_main.c index 02951f6ed8..c7059281fa 100644 --- a/legacy/ecore/src/lib/ecore/ecore_main.c +++ b/legacy/ecore/src/lib/ecore/ecore_main.c @@ -47,6 +47,7 @@ static int in_main_loop = 0; static int do_quit = 0; static Ecore_Fd_Handler *fd_handlers = NULL; static int fd_handlers_delete_me = 0; +static int (*main_loop_select)(int , fd_set *, fd_set *, fd_set *, struct timeval *) = select; static double t1 = 0.0; static double t2 = 0.0; @@ -109,6 +110,37 @@ ecore_main_loop_quit(void) do_quit = 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. + * + * 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. + * + * @warning you don't know how to use, don't even try to use it. + * + * @ingroup Ecore_Main_Loop_Group + */ +EAPI void +ecore_main_loop_select_func_set(int (*func)(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout)) +{ + main_loop_select = func; +} + +/** + * Gets the select function set by ecore_select_func_set(), + * or the native select function if none was set. + * + * @ingroup Ecore_Main_Loop_Group + */ +EAPI void * +ecore_main_loop_select_func_get(void) +{ + return main_loop_select; +} + /** * @defgroup Ecore_FD_Handler_Group File Event Handling Functions * @@ -361,7 +393,7 @@ _ecore_main_select(double timeout) } if (_ecore_signal_count_get()) return -1; - ret = select(max_fd + 1, &rfds, &wfds, &exfds, t); + ret = main_loop_select(max_fd + 1, &rfds, &wfds, &exfds, t); _ecore_loop_time = ecore_time_get(); if (ret < 0) {