aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGustavo Sverzut Barbieri <barbieri@profusion.mobi>2016-12-07 16:55:42 -0200
committerGustavo Sverzut Barbieri <barbieri@profusion.mobi>2016-12-08 11:40:45 -0200
commitbb5f91273c68e350fbe4aeeb282942c1bd017178 (patch)
tree4099a89d587cb7ad9e74b57a869353bc29ba8921
parenteina_btlog: flush stdout for each line. (diff)
downloadefl-bb5f91273c68e350fbe4aeeb282942c1bd017178.tar.gz
efl_io_buffered_stream: property and event 'progress'
useful to get feedback on when data was actually sent/received, and how much.
-rw-r--r--src/lib/ecore/efl_io_buffered_stream.c27
-rw-r--r--src/lib/ecore/efl_io_buffered_stream.eo10
2 files changed, 37 insertions, 0 deletions
diff --git a/src/lib/ecore/efl_io_buffered_stream.c b/src/lib/ecore/efl_io_buffered_stream.c
index f75c033aea..69ea69c35e 100644
--- a/src/lib/ecore/efl_io_buffered_stream.c
+++ b/src/lib/ecore/efl_io_buffered_stream.c
@@ -35,6 +35,13 @@ _efl_io_buffered_stream_error(void *data, const Efl_Event *event)
}
static void
+_efl_io_buffered_stream_copier_progress(void *data, const Efl_Event *event EINA_UNUSED)
+{
+ Eo *o = data;
+ efl_event_callback_call(o, EFL_IO_BUFFERED_STREAM_EVENT_PROGRESS, NULL);
+}
+
+static void
_efl_io_buffered_stream_incoming_can_read_changed(void *data, const Efl_Event *event)
{
Eo *o = data;
@@ -69,6 +76,7 @@ _efl_io_buffered_stream_receiver_done(void *data, const Efl_Event *event EINA_UN
}
EFL_CALLBACKS_ARRAY_DEFINE(_efl_io_buffered_stream_receiver_cbs,
+ { EFL_IO_COPIER_EVENT_PROGRESS, _efl_io_buffered_stream_copier_progress },
{ EFL_IO_COPIER_EVENT_DONE, _efl_io_buffered_stream_receiver_done },
{ EFL_IO_COPIER_EVENT_LINE, _efl_io_buffered_stream_receiver_line },
{ EFL_IO_COPIER_EVENT_ERROR, _efl_io_buffered_stream_error });
@@ -90,12 +98,16 @@ _efl_io_buffered_stream_sender_done(void *data, const Efl_Event *event EINA_UNUS
{
Eo *o = data;
Efl_Io_Buffered_Stream_Data *pd = efl_data_scope_get(o, MY_CLASS);
+ efl_ref(o);
+ efl_event_callback_call(o, EFL_IO_BUFFERED_STREAM_EVENT_PROGRESS, NULL);
efl_event_callback_call(o, EFL_IO_BUFFERED_STREAM_EVENT_WRITE_FINISHED, NULL);
if (efl_io_copier_done_get(pd->receiver))
efl_event_callback_call(o, EFL_IO_BUFFERED_STREAM_EVENT_FINISHED, NULL);
+ efl_unref(o);
}
EFL_CALLBACKS_ARRAY_DEFINE(_efl_io_buffered_stream_sender_cbs,
+ { EFL_IO_COPIER_EVENT_PROGRESS, _efl_io_buffered_stream_copier_progress },
{ EFL_IO_COPIER_EVENT_DONE, _efl_io_buffered_stream_sender_done },
{ EFL_IO_COPIER_EVENT_ERROR, _efl_io_buffered_stream_error });
@@ -262,10 +274,13 @@ _efl_io_buffered_stream_efl_io_reader_eos_set(Eo *o, Efl_Io_Buffered_Stream_Data
pd->eos = is_eos;
if (!is_eos) return;
+ efl_ref(o);
+ efl_event_callback_call(o, EFL_IO_BUFFERED_STREAM_EVENT_PROGRESS, NULL);
efl_event_callback_call(o, EFL_IO_READER_EVENT_EOS, NULL);
efl_event_callback_call(o, EFL_IO_BUFFERED_STREAM_EVENT_READ_FINISHED, NULL);
if (efl_io_copier_done_get(pd->sender))
efl_event_callback_call(o, EFL_IO_BUFFERED_STREAM_EVENT_FINISHED, NULL);
+ efl_unref(o);
}
EOLIAN static Eina_Error
@@ -482,6 +497,18 @@ _efl_io_buffered_stream_pending_read_get(Eo *o EINA_UNUSED, Efl_Io_Buffered_Stre
return efl_io_queue_usage_get(pd->incoming);
}
+EOLIAN static void
+_efl_io_buffered_stream_progress_get(Eo *o EINA_UNUSED, Efl_Io_Buffered_Stream_Data *pd, size_t *pr, size_t *pw)
+{
+ size_t r = 0, w = 0;
+
+ if (pd->sender) efl_io_copier_progress_get(pd->sender, NULL, &w, NULL);
+ if (pd->receiver) efl_io_copier_progress_get(pd->receiver, &r, NULL, NULL);
+
+ if (pr) *pr = r;
+ if (pw) *pw = w;
+}
+
EOLIAN static Eina_Bool
_efl_io_buffered_stream_slice_get(Eo *o EINA_UNUSED, Efl_Io_Buffered_Stream_Data *pd, Eina_Slice *slice)
{
diff --git a/src/lib/ecore/efl_io_buffered_stream.eo b/src/lib/ecore/efl_io_buffered_stream.eo
index 28049c4078..e8a7b52e46 100644
--- a/src/lib/ecore/efl_io_buffered_stream.eo
+++ b/src/lib/ecore/efl_io_buffered_stream.eo
@@ -146,6 +146,15 @@ class Efl.Io.Buffered_Stream (Efl.Loop_User, Efl.Io.Reader, Efl.Io.Writer, Efl.I
}
}
+ @property progress {
+ [[How many bytes were written and read.]]
+ get { }
+ values {
+ read_bytes: size; [[Bytes that were read until now]]
+ written_bytes: size; [[Bytes that were written until now]]
+ }
+ }
+
slice_get { // TODO: property and return of Eina.Slice (not pointer)
[[Get a temporary access to input queue's internal read memory.
@@ -231,6 +240,7 @@ class Efl.Io.Buffered_Stream (Efl.Loop_User, Efl.Io.Reader, Efl.Io.Writer, Efl.I
read,finished; [[Same as @Efl.Io.Reader "eos", for consistency.]]
finished; [[Both read and write are finished.]]
error: Eina.Error; [[An error happened and the I/O stopped]]
+ progress; [[Property @.progress changed]]
slice,changed; [[The read-slice returned by @.slice_get may have changed.]]
line: ptr(const(Eina.Slice)); [[If @.line_delimiter is set, will be emitted with current line. The memory is only valid during event callback dispatched and should not be modified. Note that the line slice may not be inside @.slice_get, don't assume that!]]
}