summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGustavo Sverzut Barbieri <barbieri@profusion.mobi>2016-11-24 01:03:45 -0200
committerGustavo Sverzut Barbieri <barbieri@profusion.mobi>2016-11-24 02:11:56 -0200
commit49399b385b8ebb1313a5709ae64c9bc6ebb4474e (patch)
treed6b97cf41494c4f2d3bcbb568b264de3d77c5b3f
parent7edc1ef49dec99517a4eba780ac872a9ccc7957c (diff)
downloadefl-49399b385b8ebb1313a5709ae64c9bc6ebb4474e.tar.gz
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.
-rw-r--r--src/lib/ecore/efl_io_stderr.c21
-rw-r--r--src/lib/ecore/efl_io_stderr.eo1
-rw-r--r--src/lib/ecore/efl_io_stdin.c21
-rw-r--r--src/lib/ecore/efl_io_stdin.eo1
-rw-r--r--src/lib/ecore/efl_io_stdout.c21
-rw-r--r--src/lib/ecore/efl_io_stdout.eo1
6 files changed, 63 insertions, 3 deletions
diff --git a/src/lib/ecore/efl_io_stderr.c b/src/lib/ecore/efl_io_stderr.c
index b6090280f2..6992901672 100644
--- a/src/lib/ecore/efl_io_stderr.c
+++ b/src/lib/ecore/efl_io_stderr.c
@@ -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"
diff --git a/src/lib/ecore/efl_io_stderr.eo b/src/lib/ecore/efl_io_stderr.eo
index 5da5641515..d7ec5d5e33 100644
--- a/src/lib/ecore/efl_io_stderr.eo
+++ b/src/lib/ecore/efl_io_stderr.eo
@@ -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;
}
}
diff --git a/src/lib/ecore/efl_io_stdin.c b/src/lib/ecore/efl_io_stdin.c
index 679068b7a9..6da700ec81 100644
--- a/src/lib/ecore/efl_io_stdin.c
+++ b/src/lib/ecore/efl_io_stdin.c
@@ -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"
diff --git a/src/lib/ecore/efl_io_stdin.eo b/src/lib/ecore/efl_io_stdin.eo
index 4a865581ed..421341a3db 100644
--- a/src/lib/ecore/efl_io_stdin.eo
+++ b/src/lib/ecore/efl_io_stdin.eo
@@ -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;
}
}
diff --git a/src/lib/ecore/efl_io_stdout.c b/src/lib/ecore/efl_io_stdout.c
index df20c9fb91..026d79b290 100644
--- a/src/lib/ecore/efl_io_stdout.c
+++ b/src/lib/ecore/efl_io_stdout.c
@@ -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"
diff --git a/src/lib/ecore/efl_io_stdout.eo b/src/lib/ecore/efl_io_stdout.eo
index 0dcc6eb2b5..b05fcdce16 100644
--- a/src/lib/ecore/efl_io_stdout.eo
+++ b/src/lib/ecore/efl_io_stdout.eo
@@ -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;
}
}