evas_async_events.c | evas_async_events.c | |||
---|---|---|---|---|
skipping to change at line 22 | skipping to change at line 22 | |||
#endif | #endif | |||
#include "evas_common.h" | #include "evas_common.h" | |||
#include "evas_private.h" | #include "evas_private.h" | |||
#ifdef BUILD_ASYNC_EVENTS | #ifdef BUILD_ASYNC_EVENTS | |||
static int _fd_write = -1; | static int _fd_write = -1; | |||
static int _fd_read = -1; | static int _fd_read = -1; | |||
static pid_t _fd_pid = 0; | ||||
static int _init_evas_event = 0; | static int _init_evas_event = 0; | |||
typedef struct _Evas_Event_Async Evas_Event_Async; | typedef struct _Evas_Event_Async Evas_Event_Async; | |||
struct _Evas_Event_Async | struct _Evas_Event_Async | |||
{ | { | |||
const void *target; | const void *target; | |||
void *event_info; | void *event_info; | |||
Evas_Async_Events_Put_Cb func; | Evas_Async_Events_Put_Cb func; | |||
skipping to change at line 43 | skipping to change at line 44 | |||
}; | }; | |||
int | int | |||
evas_async_events_init(void) | evas_async_events_init(void) | |||
{ | { | |||
int filedes[2]; | int filedes[2]; | |||
_init_evas_event++; | _init_evas_event++; | |||
if (_init_evas_event > 1) return _init_evas_event; | if (_init_evas_event > 1) return _init_evas_event; | |||
_fd_pid = getpid(); | ||||
if (pipe(filedes) == -1) | if (pipe(filedes) == -1) | |||
{ | { | |||
_init_evas_event = 0; | _init_evas_event = 0; | |||
return 0; | return 0; | |||
} | } | |||
_fd_read = filedes[0]; | _fd_read = filedes[0]; | |||
_fd_write = filedes[1]; | _fd_write = filedes[1]; | |||
fcntl(_fd_read, F_SETFL, O_NONBLOCK); | fcntl(_fd_read, F_SETFL, O_NONBLOCK); | |||
skipping to change at line 71 | skipping to change at line 74 | |||
if (_init_evas_event > 0) return _init_evas_event; | if (_init_evas_event > 0) return _init_evas_event; | |||
close(_fd_read); | close(_fd_read); | |||
close(_fd_write); | close(_fd_write); | |||
_fd_read = -1; | _fd_read = -1; | |||
_fd_write = -1; | _fd_write = -1; | |||
return _init_evas_event; | return _init_evas_event; | |||
} | } | |||
static void | ||||
_evas_async_events_fork_handle(void) | ||||
{ | ||||
int i, count = _init_evas_event; | ||||
if (getpid() == _fd_pid) return; | ||||
for (i = 0; i < count; i++) evas_async_events_shutdown(); | ||||
for (i = 0; i < count; i++) evas_async_events_init(); | ||||
} | ||||
#endif | #endif | |||
EAPI int | EAPI int | |||
evas_async_events_fd_get(void) | evas_async_events_fd_get(void) | |||
{ | { | |||
#ifdef BUILD_ASYNC_EVENTS | #ifdef BUILD_ASYNC_EVENTS | |||
_evas_async_events_fork_handle(); | ||||
return _fd_read; | return _fd_read; | |||
#else | #else | |||
return -1; | return -1; | |||
#endif | #endif | |||
} | } | |||
EAPI int | EAPI int | |||
evas_async_events_process(void) | evas_async_events_process(void) | |||
{ | { | |||
#ifdef BUILD_ASYNC_EVENTS | #ifdef BUILD_ASYNC_EVENTS | |||
Evas_Event_Async *ev; | Evas_Event_Async *ev; | |||
int check; | int check; | |||
int count = 0; | int count = 0; | |||
if (_fd_read == -1) return 0; | if (_fd_read == -1) return 0; | |||
_evas_async_events_fork_handle(); | ||||
do | do | |||
{ | { | |||
check = read(_fd_read, &ev, sizeof (Evas_Event_Async *)); | check = read(_fd_read, &ev, sizeof (Evas_Event_Async *)); | |||
if (check == sizeof (Evas_Event_Async *)) | if (check == sizeof (Evas_Event_Async *)) | |||
{ | { | |||
if (ev->func) ev->func((void *)ev->target, ev->type, ev->event _info); | if (ev->func) ev->func((void *)ev->target, ev->type, ev->event _info); | |||
free(ev); | free(ev); | |||
count++; | count++; | |||
} | } | |||
skipping to change at line 137 | skipping to change at line 153 | |||
evas_async_events_put(const void *target, Evas_Callback_Type type, void *ev ent_info, Evas_Async_Events_Put_Cb func) | evas_async_events_put(const void *target, Evas_Callback_Type type, void *ev ent_info, Evas_Async_Events_Put_Cb func) | |||
{ | { | |||
#ifdef BUILD_ASYNC_EVENTS | #ifdef BUILD_ASYNC_EVENTS | |||
Evas_Event_Async *ev; | Evas_Event_Async *ev; | |||
ssize_t check; | ssize_t check; | |||
Eina_Bool result = EINA_FALSE; | Eina_Bool result = EINA_FALSE; | |||
if (!func) return 0; | if (!func) return 0; | |||
if (_fd_write == -1) return 0; | if (_fd_write == -1) return 0; | |||
_evas_async_events_fork_handle(); | ||||
ev = calloc(1, sizeof (Evas_Event_Async)); | ev = calloc(1, sizeof (Evas_Event_Async)); | |||
if (!ev) return 0; | if (!ev) return 0; | |||
ev->func = func; | ev->func = func; | |||
ev->target = target; | ev->target = target; | |||
ev->type = type; | ev->type = type; | |||
ev->event_info = event_info; | ev->event_info = event_info; | |||
do | do | |||
{ | { | |||
End of changes. 6 change blocks. | ||||
0 lines changed or deleted | 18 lines changed or added | |||
This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/ |