Commit Graph

25 Commits

Author SHA1 Message Date
Gustavo Sverzut Barbieri 22837eacc9 efl_io_copier: remove TODO leftovers.
Copier is based on Efl.Io.Reader.can_read,changed and
Efl.Io.Writer.can_write,changed, these events do not keep being posted
until it's actually read/written, instead they trigger only once when
the property change -- unlike Efl.Loop_Fd read/write events.
2016-12-20 10:18:32 -02:00
Gustavo Sverzut Barbieri dd5cdda64b more eo simplified to use Eina_Slice instead of pointer to.
Working directly with Eina_Slice is easier than a pointer to it,
requires no validation of the pointers and is cheap since it's just
putting together size_t + void*.

However we can't hint the user of 'const(Eina.Slice)' properties as
Eolian is incorrectly generating getters as:

   const Eina_Slice class_property_get(...)

which is makes compilers complain about ignored qualifiers:

   ../src/lib/ecore/efl_io_copier.eo.h:329:7: warning: 'const' type qualifier on return type has no effect [-Wignored-qualifiers]

Leave some TODO so @q66 can fix those.
2016-12-19 15:30:56 -02:00
Gustavo Sverzut Barbieri 21759f713a yoda-style inactivity timeout.
s/inactivity_timeout/timeout_inactivity/g so it matches the EFL names
with scope first, like timeout_connect, etc.
2016-12-12 02:30:33 -02:00
Gustavo Sverzut Barbieri 83cbcf7cb5 efl_io_copier: callbacks may close the copier.
direct or indirect events may trigger the user to close the buffer.
2016-12-09 13:47:04 -02:00
Gustavo Sverzut Barbieri c33ed61e17 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.
2016-12-08 11:40:45 -02:00
Gustavo Sverzut Barbieri 16be61c7e1 efl_io_copier_flush: add may_block and ignore_line_delimiter parameters.
The may_block parameter is useful to force a flush without blocking on
read/write, sometimes particularly useful if ignore_line_delimiter is
true, then you get the data events without blocking -- as if a server
sending some content misses a trailing line delimiter, you do not want
to block on recv() but still want to flush data to user.

The ignore_line_delimiter parameter is useful if we're going to close
the copier and want to flush pending data which may exist due missing
trailing terminator. The close method will also force that if
destination can take more data.
2016-11-25 17:25:18 -02:00
Gustavo Sverzut Barbieri d9dafab785 efl_io_copier: expose 'done' property.
This property has a protected setter and will simplify both internal
implementation as well as usage.
2016-11-25 17:25:18 -02:00
Gustavo Sverzut Barbieri 44d95dd408 efl_io_copier: do not emit data events if no data is available. 2016-11-23 12:57:10 -02:00
Gustavo Sverzut Barbieri 5c961bba9b efl_io_copier: add flush method.
This method will force a read-write cycle and returns if it's fully
done or not. It may be used to force data to be written before a
handle is deleted (when one can't wait for the data to be written
asynchronously).
2016-11-23 12:57:10 -02:00
Gustavo Sverzut Barbieri 9a13816fb3 efl_io_copier: do not ERROR on EAGAIN.
As done by write, if we try to read and we can't, then don't give
up. This happens with streams that wraps another, like SSL, may report
there are data to read, but once you try it may not result in enough
data to upper layers.
2016-10-31 19:38:22 -02:00
Gustavo Sverzut Barbieri 574e4b8ad5 efl_io_copier: work around efl_future weirdness.
The pointer given to efl_future_use() should be NULL-ified before
calling my function, since that pointer has no meaning anymore.

The copier relied on pd->job being NULL to avoid useless rescheduling,
it was being reached with non-null, but that pointer is no longer
useful.

Moreover, I'm not sure if the second pointer, with the new future
won't be modified to NULL when the efl_future continues :-(
2016-10-26 23:19:46 -02:00
Gustavo Sverzut Barbieri bcd60581eb efl_io_copier: on close, emit "done" if still pending.
done event must be emitted before "closed" in order to notify it won't
do anything else.
2016-10-22 12:04:25 -02:00
Gustavo Sverzut Barbieri 5e54c3aa57 efl_io_copier: add inactivity_timeout.
This is handful to error the copier with ETIMEDOUT if there are no
reads or writes in the given amount of time.

Since copiers are usable to download data or handle network clients,
it's easy to set a timeout and disconnect, let's say UDP clients that
are gone.
2016-10-22 10:52:22 -02:00
Gustavo Sverzut Barbieri aba1223145 efl_io_copier: always cancel job on destructor.
It's already deleted on close(), but that's now optional
(close_on_destructor).
2016-10-20 18:49:41 -02:00
Jean-Philippe Andre 7f6f282210 Efl.Loop.User: Use prefix to rename efl_loop_user_loop_get
efl_loop_user_loop_get is idiotic. efl_loop_get should be good enough.
2016-10-06 12:24:59 +09:00
Cedric BAIL 72f0bfa224 ecore,ecore_con: simplify destructor by linking future life cycle with object. 2016-09-21 16:19:53 -07:00
Cedric Bail 03797a33ab ecore,ecore_con: fix migration to efl_future.
Efl_Future actually work with weak reference. So you do not need to
set things to NULL, but you actually need to register the memory location
of the future with efl_future_use.
2016-09-16 19:13:59 -07:00
Cedric Bail 802b146038 ecore_con: forgotten update of Eina_Promise to Efl_Future convertion due to git rebase. 2016-09-15 21:51:15 -07:00
Cedric Bail 95093095f3 ecore_con: migrate use of Eina_Promise to Efl_Future. 2016-09-15 21:49:08 -07:00
Gustavo Sverzut Barbieri ea7bc821d5 efl_io_closer: add close_on_exec and close_on_destructor properties.
the purpose of these properties are to make it more uniform the
handling of these auto-close behavior.
2016-09-12 13:18:28 -03:00
Gustavo Sverzut Barbieri 4ee09c5bdb efl_io_copier: keep extra ref when calling back from job.
while in a job we do not have the safety of eo holding us alive and
when we call back the user, he may have deleted the object, releasing
both the object and its private data that we're using.

then keep an extra reference, call the methods and release it.
2016-09-02 00:08:49 -03:00
Vitor Sousa f02ff462e7 efl callbacks: update some events calls to no longer trigger legacy callbacks 2016-08-30 13:59:59 -03:00
Tom Hacohen d5e321466e Efl object: Rename Eo_Event -> Efl_Event.
This is the last step of the Eo renaming efforts.
2016-08-30 13:34:10 +01:00
Vitor Sousa 8356b16a49 Efl Object: remove legacy callback calls from event_callback_call
Efl.Object.event_callback_call no longer calls legacy smart callbacks;
calling only event callbacks registered with the given event description
pointer.

Create the method Efl.Object.event_callback_legacy_call to inherit the old
behavior from Efl.Object.event_callback_call, calling both Efl.Object events
and legacy smart callbacks.

Update all other files accordingly in order to still supply legacy
callbacks while they are necessary.
2016-08-26 15:45:07 -03:00
Gustavo Sverzut Barbieri 5d4688679e efl.io: introduce basic interfaces and classes.
These interfaces allows generic operations on objects that can store
or provide data, such as a file or a buffer.

With well defined interfaces and events we can create code such as
Efl.Io.Copier, that will link a source with a destination and
progressively copy data as they appear.
2016-08-22 18:25:14 -03:00