forked from enlightenment/efl
efl_loop_fd: reduce number of _efl_loop_fd_reset()
When we're adding callbacks in an array, we may reduce 3 epoll_ctl() to a single one.
This commit is contained in:
parent
f1b94bdf7b
commit
0a8fd379db
|
@ -97,6 +97,7 @@ _check_fd_event_catcher_add(void *data, const Efl_Event *event)
|
||||||
{
|
{
|
||||||
const Efl_Callback_Array_Item *array = event->info;
|
const Efl_Callback_Array_Item *array = event->info;
|
||||||
Efl_Loop_Fd_Data *fd = data;
|
Efl_Loop_Fd_Data *fd = data;
|
||||||
|
Eina_Bool need_reset = EINA_FALSE;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; array[i].desc != NULL; i++)
|
for (i = 0; array[i].desc != NULL; i++)
|
||||||
|
@ -104,26 +105,30 @@ _check_fd_event_catcher_add(void *data, const Efl_Event *event)
|
||||||
if (array[i].desc == EFL_LOOP_FD_EVENT_READ)
|
if (array[i].desc == EFL_LOOP_FD_EVENT_READ)
|
||||||
{
|
{
|
||||||
if (fd->references.read++ > 0) continue;
|
if (fd->references.read++ > 0) continue;
|
||||||
_efl_loop_fd_reset(event->object, fd);
|
need_reset = EINA_TRUE;
|
||||||
}
|
}
|
||||||
else if (array[i].desc == EFL_LOOP_FD_EVENT_WRITE)
|
else if (array[i].desc == EFL_LOOP_FD_EVENT_WRITE)
|
||||||
{
|
{
|
||||||
if (fd->references.write++ > 0) continue;
|
if (fd->references.write++ > 0) continue;
|
||||||
_efl_loop_fd_reset(event->object, fd);
|
need_reset = EINA_TRUE;
|
||||||
}
|
}
|
||||||
if (array[i].desc == EFL_LOOP_FD_EVENT_ERROR)
|
if (array[i].desc == EFL_LOOP_FD_EVENT_ERROR)
|
||||||
{
|
{
|
||||||
if (fd->references.error++ > 0) continue;
|
if (fd->references.error++ > 0) continue;
|
||||||
|
need_reset = EINA_TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (need_reset)
|
||||||
_efl_loop_fd_reset(event->object, fd);
|
_efl_loop_fd_reset(event->object, fd);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_check_fd_event_catcher_del(void *data, const Efl_Event *event)
|
_check_fd_event_catcher_del(void *data, const Efl_Event *event)
|
||||||
{
|
{
|
||||||
const Efl_Callback_Array_Item *array = event->info;
|
const Efl_Callback_Array_Item *array = event->info;
|
||||||
Efl_Loop_Fd_Data *fd = data;
|
Efl_Loop_Fd_Data *fd = data;
|
||||||
|
Eina_Bool need_reset = EINA_FALSE;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; array[i].desc != NULL; i++)
|
for (i = 0; array[i].desc != NULL; i++)
|
||||||
|
@ -131,20 +136,23 @@ _check_fd_event_catcher_del(void *data, const Efl_Event *event)
|
||||||
if (array[i].desc == EFL_LOOP_FD_EVENT_READ)
|
if (array[i].desc == EFL_LOOP_FD_EVENT_READ)
|
||||||
{
|
{
|
||||||
if (fd->references.read-- > 1) continue;
|
if (fd->references.read-- > 1) continue;
|
||||||
_efl_loop_fd_reset(event->object, fd);
|
need_reset = EINA_TRUE;
|
||||||
}
|
}
|
||||||
else if (array[i].desc == EFL_LOOP_FD_EVENT_WRITE)
|
else if (array[i].desc == EFL_LOOP_FD_EVENT_WRITE)
|
||||||
{
|
{
|
||||||
if (fd->references.write-- > 1) continue;
|
if (fd->references.write-- > 1) continue;
|
||||||
_efl_loop_fd_reset(event->object, fd);
|
need_reset = EINA_TRUE;
|
||||||
}
|
}
|
||||||
if (array[i].desc == EFL_LOOP_FD_EVENT_ERROR)
|
if (array[i].desc == EFL_LOOP_FD_EVENT_ERROR)
|
||||||
{
|
{
|
||||||
if (fd->references.error-- > 1) continue;
|
if (fd->references.error-- > 1) continue;
|
||||||
|
need_reset = EINA_TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (need_reset)
|
||||||
_efl_loop_fd_reset(event->object, fd);
|
_efl_loop_fd_reset(event->object, fd);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
EFL_CALLBACKS_ARRAY_DEFINE(fd_watch,
|
EFL_CALLBACKS_ARRAY_DEFINE(fd_watch,
|
||||||
{ EFL_EVENT_CALLBACK_ADD, _check_fd_event_catcher_add },
|
{ EFL_EVENT_CALLBACK_ADD, _check_fd_event_catcher_add },
|
||||||
|
|
Loading…
Reference in New Issue