forked from enlightenment/efl
efl_io_std{in,out,err}: do not spin on fd monitoring events.
as soon as we report 'can_read' or 'can_write', stop monitoring the events until the user executes the operation, which will clear these flags and we resume monitoring.
This commit is contained in:
parent
7edc1ef49d
commit
49399b385b
|
@ -38,7 +38,6 @@ _efl_io_stderr_efl_object_finalize(Eo *o, void *pd EINA_UNUSED)
|
|||
o = efl_finalize(efl_super(o, MY_CLASS));
|
||||
if (!o) return NULL;
|
||||
|
||||
// TODO: only register "write" if "can_write" is being monitored?
|
||||
efl_event_callback_add(o, EFL_LOOP_FD_EVENT_WRITE, _efl_io_stderr_event_write, NULL);
|
||||
efl_event_callback_add(o, EFL_LOOP_FD_EVENT_ERROR, _efl_io_stderr_event_error, NULL);
|
||||
|
||||
|
@ -57,4 +56,24 @@ _efl_io_stderr_efl_io_writer_write(Eo *o, void *pd EINA_UNUSED, Eina_Slice *ro_s
|
|||
return ret;
|
||||
}
|
||||
|
||||
EOLIAN static void
|
||||
_efl_io_stderr_efl_io_writer_can_write_set(Eo *o, void *pd EINA_UNUSED, Eina_Bool value)
|
||||
{
|
||||
Eina_Bool old = efl_io_writer_can_write_get(o);
|
||||
if (old == value) return;
|
||||
|
||||
efl_io_writer_can_write_set(efl_super(o, MY_CLASS), value);
|
||||
|
||||
if (value)
|
||||
{
|
||||
/* stop monitoring the FD, we need to wait the user to write and clear the kernel flag */
|
||||
efl_event_callback_del(o, EFL_LOOP_FD_EVENT_WRITE, _efl_io_stderr_event_write, NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* kernel flag is clear, resume monitoring the FD */
|
||||
efl_event_callback_add(o, EFL_LOOP_FD_EVENT_WRITE, _efl_io_stderr_event_write, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
#include "efl_io_stderr.eo.c"
|
||||
|
|
|
@ -10,5 +10,6 @@ class Efl.Io.Stderr (Efl.Loop.Fd, Efl.Io.Writer.Fd) {
|
|||
Efl.Object.finalize;
|
||||
Efl.Loop.Fd.fd.set;
|
||||
Efl.Io.Writer.write;
|
||||
Efl.Io.Writer.can_write.set;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,7 +40,6 @@ _efl_io_stdin_efl_object_finalize(Eo *o, void *pd EINA_UNUSED)
|
|||
o = efl_finalize(efl_super(o, MY_CLASS));
|
||||
if (!o) return NULL;
|
||||
|
||||
// TODO: only register "read" if "can_read" is being monitored?
|
||||
efl_event_callback_add(o, EFL_LOOP_FD_EVENT_READ, _efl_io_stdin_event_read, NULL);
|
||||
efl_event_callback_add(o, EFL_LOOP_FD_EVENT_ERROR, _efl_io_stdin_event_error, NULL);
|
||||
return o;
|
||||
|
@ -58,4 +57,24 @@ _efl_io_stdin_efl_io_reader_read(Eo *o, void *pd EINA_UNUSED, Eina_Rw_Slice *rw_
|
|||
return ret;
|
||||
}
|
||||
|
||||
EOLIAN static void
|
||||
_efl_io_stdin_efl_io_reader_can_read_set(Eo *o, void *pd EINA_UNUSED, Eina_Bool value)
|
||||
{
|
||||
Eina_Bool old = efl_io_reader_can_read_get(o);
|
||||
if (old == value) return;
|
||||
|
||||
efl_io_reader_can_read_set(efl_super(o, MY_CLASS), value);
|
||||
|
||||
if (value)
|
||||
{
|
||||
/* stop monitoring the FD, we need to wait the user to read and clear the kernel flag */
|
||||
efl_event_callback_del(o, EFL_LOOP_FD_EVENT_READ, _efl_io_stdin_event_read, NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* kernel flag is clear, resume monitoring the FD */
|
||||
efl_event_callback_add(o, EFL_LOOP_FD_EVENT_READ, _efl_io_stdin_event_read, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
#include "efl_io_stdin.eo.c"
|
||||
|
|
|
@ -10,5 +10,6 @@ class Efl.Io.Stdin (Efl.Loop.Fd, Efl.Io.Reader.Fd) {
|
|||
Efl.Object.finalize;
|
||||
Efl.Loop.Fd.fd.set;
|
||||
Efl.Io.Reader.read;
|
||||
Efl.Io.Reader.can_read.set;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,7 +38,6 @@ _efl_io_stdout_efl_object_finalize(Eo *o, void *pd EINA_UNUSED)
|
|||
o = efl_finalize(efl_super(o, MY_CLASS));
|
||||
if (!o) return NULL;
|
||||
|
||||
// TODO: only register "write" if "can_write" is being monitored?
|
||||
efl_event_callback_add(o, EFL_LOOP_FD_EVENT_WRITE, _efl_io_stdout_event_write, NULL);
|
||||
efl_event_callback_add(o, EFL_LOOP_FD_EVENT_ERROR, _efl_io_stdout_event_error, NULL);
|
||||
return o;
|
||||
|
@ -56,4 +55,24 @@ _efl_io_stdout_efl_io_writer_write(Eo *o, void *pd EINA_UNUSED, Eina_Slice *ro_s
|
|||
return ret;
|
||||
}
|
||||
|
||||
EOLIAN static void
|
||||
_efl_io_stdout_efl_io_writer_can_write_set(Eo *o, void *pd EINA_UNUSED, Eina_Bool value)
|
||||
{
|
||||
Eina_Bool old = efl_io_writer_can_write_get(o);
|
||||
if (old == value) return;
|
||||
|
||||
efl_io_writer_can_write_set(efl_super(o, MY_CLASS), value);
|
||||
|
||||
if (value)
|
||||
{
|
||||
/* stop monitoring the FD, we need to wait the user to write and clear the kernel flag */
|
||||
efl_event_callback_del(o, EFL_LOOP_FD_EVENT_WRITE, _efl_io_stdout_event_write, NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* kernel flag is clear, resume monitoring the FD */
|
||||
efl_event_callback_add(o, EFL_LOOP_FD_EVENT_WRITE, _efl_io_stdout_event_write, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
#include "efl_io_stdout.eo.c"
|
||||
|
|
|
@ -10,5 +10,6 @@ class Efl.Io.Stdout (Efl.Loop.Fd, Efl.Io.Writer.Fd) {
|
|||
Efl.Object.finalize;
|
||||
Efl.Loop.Fd.fd.set;
|
||||
Efl.Io.Writer.write;
|
||||
Efl.Io.Writer.can_write.set;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue