From 86cf33e33539bbaf5032e6599cafca0fddf3110b Mon Sep 17 00:00:00 2001 From: cedric Date: Mon, 30 May 2011 16:52:19 +0000 Subject: [PATCH] ecore: add ecore_pipe_freeze/thraw. git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/ecore@59823 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33 --- ChangeLog | 9 +++++++-- src/lib/ecore/Ecore.h | 2 ++ src/lib/ecore/ecore_pipe.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 55 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 62ec54d..34d9b51 100644 --- a/ChangeLog +++ b/ChangeLog @@ -192,16 +192,21 @@ * Fix Ecore_X shadow tree search handling to respect shape and shape input of windows. -2011-05-20 Daniel Juyung Seo (SeoZ) +2011-05-20 Daniel Juyung Seo (SeoZ) * Ecore ecore_main.c: Fixed ecore_main_loop (_ecore_main_loop_iterate_internal). This fixes fd handler pending issue when ecore_idler callback adds ecore_job/event. * Ecore ecore_main.c: Refactoring _ecore_main_loop_iterate_internal(). -2011-05-27 Gustavo Sverzut Barbieri (k-s) +2011-05-27 Gustavo Sverzut Barbieri (k-s) * Ecore_X: introduce ecore_x_screen_size_get() * Ecore_Evas: be safer when returning Ecore_Evas* from ecore_evas_ecore_evas_get() * Ecore_Evas: introduce ecore_evas_screen_geometry_get() + +2011-05-30 Cedric Bail + + * Add ecore_pipe_freeze/thraw to suspend and restart watching the pipe + inside the main loop. diff --git a/src/lib/ecore/Ecore.h b/src/lib/ecore/Ecore.h index 84a3214..de62746 100644 --- a/src/lib/ecore/Ecore.h +++ b/src/lib/ecore/Ecore.h @@ -786,6 +786,8 @@ extern "C" { EAPI Eina_Bool ecore_pipe_write(Ecore_Pipe *p, const void *buffer, unsigned int nbytes); EAPI void ecore_pipe_write_close(Ecore_Pipe *p); EAPI void ecore_pipe_read_close(Ecore_Pipe *p); + EAPI void ecore_pipe_thraw(Ecore_Pipe *p); + EAPI void ecore_pipe_freeze(Ecore_Pipe *p); /** * @} diff --git a/src/lib/ecore/ecore_pipe.c b/src/lib/ecore/ecore_pipe.c index bd6efa1..a3fe7c9 100644 --- a/src/lib/ecore/ecore_pipe.c +++ b/src/lib/ecore/ecore_pipe.c @@ -368,6 +368,52 @@ ecore_pipe_read_close(Ecore_Pipe *p) } /** + * Stop monitoring if necessary the pipe for reading. See ecore_pipe_thraw() + * for monitoring it again. + * + * @param p The Ecore_Pipe object. + */ +EAPI void +ecore_pipe_freeze(Ecore_Pipe *p) +{ + if (!ECORE_MAGIC_CHECK(p, ECORE_MAGIC_PIPE)) + { + ECORE_MAGIC_FAIL(p, ECORE_MAGIC_PIPE, "ecore_pipe_read_close"); + return; + } + if (p->fd_handler) + { + ecore_main_fd_handler_del(p->fd_handler); + p->fd_handler = NULL; + } +} + +/** + * Start monitoring again the pipe for reading. See ecore_pipe_freeze() for + * stopping the monitoring activity. This will not work if + * ecore_pipe_read_close() was previously called on the same pipe. + * + * @param p The Ecore_Pipe object. + */ +EAPI void +ecore_pipe_thraw(Ecore_Pipe *p) +{ + if (!ECORE_MAGIC_CHECK(p, ECORE_MAGIC_PIPE)) + { + ECORE_MAGIC_FAIL(p, ECORE_MAGIC_PIPE, "ecore_pipe_read_close"); + return; + } + if (!p->fd_handler && p->fd_read != PIPE_FD_INVALID) + { + p->fd_handler = ecore_main_fd_handler_add(p->fd_read, + ECORE_FD_READ, + _ecore_pipe_read, + p, + NULL, NULL); + } +} + +/** * Close the write end of an Ecore_Pipe object created with ecore_pipe_add(). * * @param p The Ecore_Pipe object. -- 2.7.4