summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGustavo Sverzut Barbieri <barbieri@profusion.mobi>2016-12-07 17:31:48 -0200
committerGustavo Sverzut Barbieri <barbieri@profusion.mobi>2016-12-08 11:40:45 -0200
commitc33ed61e1735020953b67f1049c11cedd51950dc (patch)
tree74f76a8265eb5b0e705e707433327bd9332509e8
parentbb5f91273c68e350fbe4aeeb282942c1bd017178 (diff)
downloadefl-c33ed61e1735020953b67f1049c11cedd51950dc.tar.gz
efl_io_copier: expose pending_size and add debug to done_get.
In some cases the copier isn't done but you know there is not more data to arrive at it, then you want to know if all pending data was flushed from the copier's intermediate buffer to the destination, if so you can call it closed yourself.
-rw-r--r--src/lib/ecore/efl_io_copier.c21
-rw-r--r--src/lib/ecore/efl_io_copier.eo17
2 files changed, 36 insertions, 2 deletions
diff --git a/src/lib/ecore/efl_io_copier.c b/src/lib/ecore/efl_io_copier.c
index c92a8efca0..78d14f1fe2 100644
--- a/src/lib/ecore/efl_io_copier.c
+++ b/src/lib/ecore/efl_io_copier.c
@@ -781,9 +781,26 @@ _efl_io_copier_flush(Eo *o, Efl_Io_Copier_Data *pd, Eina_Bool may_block, Eina_Bo
return pd->done;
}
-EOLIAN static Eina_Bool
-_efl_io_copier_done_get(Eo *o EINA_UNUSED, Efl_Io_Copier_Data *pd)
+EOLIAN static size_t
+_efl_io_copier_pending_size_get(Eo *o EINA_UNUSED, Efl_Io_Copier_Data *pd)
{
+ return pd->buf ? eina_binbuf_length_get(pd->buf) : 0;
+}
+
+EOLIAN static Eina_Bool
+_efl_io_copier_done_get(Eo *o, Efl_Io_Copier_Data *pd)
+{
+ DBG("%p done=%d pending=%zd source={%p %s, eos=%d, closed=%d}, destination={%p %s, closed=%d}",
+ o, pd->done,
+ pd->buf ? eina_binbuf_length_get(pd->buf) : 0,
+ pd->source,
+ pd->source ? efl_class_name_get(pd->source) : "",
+ pd->source ? efl_io_reader_eos_get(pd->source) : 1,
+ pd->source ? (efl_isa(pd->source, EFL_IO_CLOSER_MIXIN) ? efl_io_closer_closed_get(pd->source) : 0) : 1,
+ pd->destination,
+ pd->destination ? efl_class_name_get(pd->destination) : "",
+ pd->destination ? (efl_isa(pd->destination, EFL_IO_CLOSER_MIXIN) ? efl_io_closer_closed_get(pd->destination) : 0) : 1);
+
return pd->done;
}
diff --git a/src/lib/ecore/efl_io_copier.eo b/src/lib/ecore/efl_io_copier.eo
index 36ad624843..23198e8fc1 100644
--- a/src/lib/ecore/efl_io_copier.eo
+++ b/src/lib/ecore/efl_io_copier.eo
@@ -313,6 +313,23 @@ class Efl.Io.Copier (Efl.Loop_User, Efl.Io.Closer) {
return: free(own(ptr(Eina.Binbuf)), eina_binbuf_free) @warn_unused; [[Binbuf]]
}
+ @property pending_size {
+ [[Returns the size of the pending buffer.
+
+ The pending buffer is an intermediate buffer where data
+ is read from @.source before it's written to
+ @.destination, if any.
+
+ This is the equivalent of the size of returned by
+ @.binbuf_steal, however it doesn't steal or modify the
+ buffer at all, just query its internal size.
+ ]]
+ get { }
+ values {
+ size: size; [[The pending buffer size, in bytes.]]
+ }
+ }
+
flush {
[[Forces reading from source and writing to destination.