ecore: add ecore_fork_reset()

SVN revision: 75045
This commit is contained in:
Cedric BAIL 2012-08-09 12:17:47 +00:00
parent addf4cccd0
commit 6aefa60a0a
4 changed files with 20 additions and 8 deletions

View File

@ -851,3 +851,4 @@
2012-08-09 Cedric Bail
* Correctly shutdown Ecore_Thread.
* Add a way to reset Ecore_Thread internal pipe after a fork via ecore_fork_reset.

View File

@ -6,6 +6,7 @@ Changes since Ecore 1.2.0:
Additions:
* ecore:
- Add ecore_main_fd_handler_file_add()
- Add ecore_fork_reset()
* ecore_evas:
- Add transparency support on Windows (GDI engine only)
- Add API functions to get/set an Ecore_Evas's profile.

View File

@ -373,13 +373,14 @@ extern "C" {
#endif
/**
* @defgroup Ecore_Init_Group Ecore initialization and shutdown functions.
* @defgroup Ecore_Init_Group Ecore initialization, shutdown functions and reset on fork.
*
* @{
*/
EAPI int ecore_init(void);
EAPI int ecore_shutdown(void);
EAPI void ecore_fork_reset(void);
/**
* @}

View File

@ -80,6 +80,7 @@ static void _thread_callback(void *data,
static Eina_List *_thread_cb = NULL;
static Ecore_Pipe *_thread_call = NULL;
static Eina_Lock _thread_safety;
static const int wakeup = 42;
static int _thread_loop = 0;
static Eina_Lock _thread_mutex;
@ -175,11 +176,8 @@ ecore_init(void)
eina_condition_new(&_thread_cond, &_thread_mutex);
eina_lock_new(&_thread_feedback_mutex);
eina_condition_new(&_thread_feedback_cond, &_thread_feedback_mutex);
if (!_thread_call)
{
_thread_call = ecore_pipe_add(_thread_callback, NULL);
eina_lock_new(&_thread_safety);
}
_thread_call = ecore_pipe_add(_thread_callback, NULL);
eina_lock_new(&_thread_safety);
eina_lock_new(&_thread_id_lock);
@ -307,12 +305,23 @@ unlock:
return _ecore_init_count;
}
EAPI void
ecore_fork_reset(void)
{
eina_lock_take(&_thread_safety);
ecore_pipe_del(_thread_call);
_thread_call = ecore_pipe_add(_thread_callback, NULL);
/* If there was something in the pipe, trigger a wakeup again */
if (_thread_cb) ecore_pipe_write(_thread_call, &wakeup, sizeof (int));
eina_lock_release(&_thread_safety);
}
/**
* @}
*/
static int wakeup = 42;
EAPI void
ecore_main_loop_thread_safe_call_async(Ecore_Cb callback,
void *data)