From: barbieri Date: Thu, 16 Apr 2009 15:44:26 +0000 (+0000) Subject: Be able to change select() function used by main loop. X-Git-Tag: build/2012-07-04.173327~2623 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=4abe01571205b93c938382d2dbe4e938c77e2d09;p=profile%2Fivi%2Fecore.git Be able to change select() function used by main loop. Patch by Kenneth Christiansen, used to integrate with GLib and other main loops. git-svn-id: http://svn.enlightenment.org/svn/e/trunk/ecore@40110 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33 --- diff --git a/src/lib/ecore/Ecore.h b/src/lib/ecore/Ecore.h index 0a1969d..84cd6c5 100644 --- a/src/lib/ecore/Ecore.h +++ b/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/src/lib/ecore/ecore_main.c b/src/lib/ecore/ecore_main.c index 02951f6..c705928 100644 --- a/src/lib/ecore/ecore_main.c +++ b/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; @@ -110,6 +111,37 @@ ecore_main_loop_quit(void) } /** + * 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 * * Functions that deal with file descriptor handlers. @@ -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) {