efl_io_buffered_stream: property and event 'progress'
useful to get feedback on when data was actually sent/received, and how much.
This commit is contained in:
parent
5242c3b1d4
commit
bb5f91273c
|
@ -34,6 +34,13 @@ _efl_io_buffered_stream_error(void *data, const Efl_Event *event)
|
|||
efl_event_callback_call(o, EFL_IO_BUFFERED_STREAM_EVENT_ERROR, event->info);
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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!]]
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue