Commit Graph

60 Commits

Author SHA1 Message Date
Cedric BAIL eb1d47349b eina: always initialize all the field of Eina_Value used by Eina_Promise.
Reviewed-by: Xavi Artigas <xavierartigas@yahoo.es>
Differential Revision: https://phab.enlightenment.org/D8794
2019-05-09 09:33:27 -07:00
Cedric BAIL e859130dd4 eina: prevent double cancel of ongoing dispatched future.
Reviewed-by: Marcel Hollerbach <mail@marcel-hollerbach.de>
Differential Revision: https://phab.enlightenment.org/D8333
2019-03-27 15:03:08 -07:00
Cedric BAIL 7331f21ea7 eina: always initialize i.
Reviewers: zmike, bu5hm4n, stefan_schmidt, devilhorns

Reviewed By: devilhorns

Subscribers: #reviewers, #committers

Tags: #efl

Differential Revision: https://phab.enlightenment.org/D8451
2019-03-26 12:05:02 -04:00
Cedric BAIL 7889f71c7b eina: fix memory leak when a Eina_Value as promise is returned, but no dispatching Eina_Future is listening on it.
Reviewed-by: SangHyeon Jade Lee <sh10233.lee@samsung.com>
Differential Revision: https://phab.enlightenment.org/D7652
2019-01-23 12:07:17 -08:00
Cedric BAIL ba80dfe3f4 eina: remove eina_promise_data_get has it lead to risky use.
It seems that use of eina_promise_data_get lead to mostly missuse. As it
duplicate other infrastructure which do not have the same problem. So better
remove it and if we need it back, we can just revert this patch later.

Reviewed-by: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Differential Revision: https://phab.enlightenment.org/D7578
2019-01-16 16:10:30 -08:00
Cedric BAIL 1bbe4ceb5c eina: remove eina_promise_data_set.
eina_promise_data_set is a misleading API and result in conflicted use by
multiple independent piece of code leading to bug and crash. It is also not
necessary and we can avoid using it completely.

Reviewed-by: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Differential Revision: https://phab.enlightenment.org/D7575
2019-01-16 14:33:22 -08:00
Cedric BAIL b3d04f7200 Revert "eina: add a function to free Eina_Promise attached data when the promise is destroyed."
A better solution is to actually have no eina_promise_data_set/get at all.

This reverts commit ce56f32270.

Reviewed-by: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Differential Revision: https://phab.enlightenment.org/D7574
2019-01-16 14:33:20 -08:00
Cedric BAIL d67a7df9ca Revert "fix crashes created by "make efl_loop_promise_new a function""
This serie of patch didn't address the core problem in the design of the
ownership of eina_promise_data_{set/get} usage. It is also redundant with
other infrastructure in eina_promise and so not necessary completely.

This reverts commit de2ec0559b.

Reviewed-by: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Differential Revision: https://phab.enlightenment.org/D7573
2019-01-16 14:33:18 -08:00
Carsten Haitzler de2ec0559b fix crashes created by "make efl_loop_promise_new a function"
commit 9b5155c9f1 brought about crashes
- specifically that i saw in terminology because it actually uses
eina_promise_data_set() and the new efl_loop_promise_new basically
took over ownership of that data, but if anyone used
eina_promise_data_set() the data ptr used by this new code would bwe
overwritten, causing segfauls when terminology loses selection
ownership. for days i had mysterious crashes of terminology until i
narrowed it down to the above, so if you have too, then this will fix
it.

what this does is create a data set intercept function callback that
for now is only for use inside efl to everride data sets so they set
data inside the new struct that tracks data. i also had to add and
intercept for eina_promise_data_free_cb_set() as this in theory could
also ber a similar problem.

so perhaps the idea/design of efl_loop_promise_new() is not right and
this kind of thgn has to be internal to eina promise... this means
eina promise and loops are much more tied together.
2018-12-26 17:49:34 +00:00
Cedric BAIL ce56f32270 eina: add a function to free Eina_Promise attached data when the promise is destroyed.
Reviewed-by: Lauro Neto <Lauro Moura <lauromoura@expertisesolutions.com.br>>
Differential Revision: https://phab.enlightenment.org/D7491
2018-12-20 12:42:33 -08:00
Cedric BAIL 3ef87a251b eina: use the correct type for casting to avoid issue on Windows.
Reviewed-by: Vincent Torri <vincent.torri@gmail.com>
Differential Revision: https://phab.enlightenment.org/D7458
2018-12-20 09:57:02 -08:00
Carsten Haitzler 665a75378f xxx - fix eina_future_then calls to pass sotrage val - fix warns 2018-11-09 11:43:59 +00:00
Carsten Haitzler 9a4e25a7a8 eina promise - warning fix - init storage field on return
fix a warning but this actually is a bug with storage being left
uninitialized.
2018-11-09 11:43:58 +00:00
Cedric BAIL b8cf656bd3 eina: actually it make more sense to do the check for EINA_VALUE_EMPTY inside eina_value_type_get. 2018-05-07 09:46:42 -07:00
Cedric BAIL 2b489d5627 eina: allow EINA_VALUE_EMPTY for Eina_Future as Eina_Value. 2018-05-07 09:34:04 -07:00
Cedric BAIL 90c2e05788 eina: Eina_Future as Eina_Value can also be cancelled. 2018-05-05 21:04:20 -07:00
Cedric Bail c0bcd32591 eina: allow EINA_VALUE_EMPTY to be propagated with eina_future_as_value. 2018-05-01 10:39:01 -07:00
Cedric BAIL 07e5064e15 eina: fix promise scheduler lookup to find it when given a resolved chain of future.
T6738
2018-03-12 11:59:33 -07:00
Carsten Haitzler 1bdd9e4dd1 ecore - a different take on efl.app class as a super class to efl.loop
so the MAIN loop is actually an efl.app object. which inherits from
efl.loop. the idea is that other loops in threads will not be efl.app
objects. thread on the creator side return an efl.thread object.
inside the thread, like the mainloop, there is now an efl.appthread
object that is for all non-main-loop threads.

every thread (main loop or child) when it spawns a thread is the
parent. there are i/o pipes from parnet to child and back. so parents
are generally expected to, if they want to talk to child thread, so
use the efl.io interfaces on efl.thread, and the main loop's elf.app
class allows you to talk to stdio back to the parent process like the
efl.appthread does the same using the efl.io interfaces to talk to its
parent app or appthread. it's symmetrical

no tests here - sure. i have been holding off on tests until things
settle. that's why i haven't done them yet. those will come back in a
subsequent commit

for really quick examples on using this see:

https://phab.enlightenment.org/F2983118
https://phab.enlightenment.org/F2983142

they are just my test code for this.

Please see this design document:

https://phab.enlightenment.org/w/efl-loops-threads/
2018-03-03 13:40:33 +09:00
Cedric Bail 79d7483fe7 eina: add eina_promise_continue_new to create a promise using an existing dead future. 2018-01-10 18:16:25 -08:00
Carsten Haitzler b27ca559f6 remove elgacy ecore event usage in futures that limit to mainloop only
also eina_procmis was not threadsafe so cannto use loops in different
threads at all until this was made safe. needed to disable the old
ecore_event using code in for ecore futures and create a new efl loop
message future and handler instead ... but now a quick experiment with
multiple loops in 10 threads plus mainloop have timers at least work.
i need to test more like fd handlers etc etc. but it's a step.
2017-12-28 02:24:12 +09:00
Cedric BAIL 90f30ea418 eina: make __eina_promise_cancel_all an internal only function. 2017-12-18 16:17:04 -08:00
Jean-Philippe Andre 5dbfb7961f eo/eina: Add HACK to avoid calls to EO after shutdown
Efl.Future is an EO object which means even cancelling Efl.Future
objects requires EO. So this should be done before shutting down EO,
otherwise everything fails badly.

I believe Efl.Future is going to disappear soon, but the problem will
remain: if any promise/future uses EO or anything else outside of Eina
(so, basically anything) then it needs to be canceled before shutting
down the above layers. This is the same situation as with ecore events,
for which we've introduced ecore_event_type_flush.

Ping @cedric
2017-12-18 19:54:31 +09:00
Cedric BAIL e474edc9f6 eina: add helper to return already known to fail future. 2017-10-25 13:39:44 -07:00
Cedric BAIL fa9acf8b35 eina: add eina_promise_data_set symetric to eina_promise_data_get. 2017-09-11 16:09:43 -07:00
Thiep Ha aced128e85 eina_promise: remove shadowed declaration warning 2017-09-05 15:56:00 +09:00
Gustavo Sverzut Barbieri d258774c2a Eina_Future: add eina_future_resolved()
This is a helper that creates a promise, then a future and immediately
resolves the promise, this will let the future be dispatched as usual,
from a clean main loop context.
2017-09-04 10:24:00 -03:00
Guilherme Iscaro 5bd8c9a78d Eina: Add Eina_Promise/Eina_Future.
This commit adds a new promise/future API which aims to replace
efl_future.
2017-09-04 10:24:00 -03:00
Cedric BAIL de131bf5d0 eina: remove Eina_Promise. 2016-11-07 13:43:11 -08:00
Stefan Schmidt 3bd4c19f55 eina: promise: fix memory leak in error path
If we would not get a promise back here the allocated array would leak when we
return. Make sure we also free it in this case.

CID: 1360468
2016-07-29 14:53:36 +02:00
Chris Michael 89234ce6bc eina: Fix null pointer derefernce
Coverity reports that eina_safepointer_get returns a NULL promise here
(checked 20 out of 21 times). As eina_safepointer_get can return NULL,
we should check the validity of 'promise' here before trying to
derefernce it later.

Fixes Coverity CID1356625

@fix

Signed-off-by: Chris Michael <cp.michael@samsung.com>
2016-07-21 13:07:26 -04:00
Felipe Magno de Almeida f33b53e923 eina: Fix race wrong prototype for unref 2016-06-14 23:08:13 -03:00
Felipe Magno de Almeida 949af55947 eina: Add support for eina_safepointer in promises 2016-06-11 10:40:27 -03:00
Lauro Moura 2d2e57eccd eina: Smudge magic value on promise deletion 2016-06-09 22:39:25 -03:00
Lauro Moura 46843551c0 eina: Remove value type promises
All values in promises are now considered as by-pointer.
2016-06-09 22:38:54 -03:00
Lauro Moura 3b090b808b eina: Fixes on promises behavior when cancelling
- Free the cancel callbacks on promise delete
- Cancelling an ended promise should be a nop
- More tests to increase coverage
2016-06-09 19:14:14 -03:00
Larry Jr 2e441c3f5e eina: eina_promise_all callback cast removed 2016-06-06 03:30:42 -03:00
Lauro Moura 47dea6abc1 eina: Avoid promise early deletion when cancelled.
Cancelling a promise will fulfill it but won't actually free the memory. This
memory is under custody of the owner, who must either call value_set or
error_set to finish it.
2016-06-06 03:09:40 -03:00
Lauro Moura b28f6f2fce eina: Fix promise tests and avoid early deletion
- Progress notify refcount fixes, avoiding early deletion
- Avoid leaking memory on tests
2016-06-05 21:58:19 -03:00
Tom Hacohen 4c3b7fb248 Eina promise: Fix broken return value.
I broke it in dc73f6644e.
Excuse of the day: I'm not working from my usual spot and there's screen glare
here that made me not see the *. Good excuse?
2016-06-05 11:00:55 +01:00
Tom Hacohen dc73f6644e Eina promise: Simplify code and remove shadow variable.
There was no need for the extra variable. This also fixes a shadow
warning.
2016-06-05 10:57:07 +01:00
Felipe Magno de Almeida 1c269cf24a eina: Fix magic check for eina_promise_owner_buffer_get 2016-06-03 21:53:29 -03:00
Felipe Magno de Almeida 2e4765bc88 eina: Fix EINA_MAGIC and eina_promise_then NULL check 2016-06-03 21:43:57 -03:00
Cedric BAIL af2b0c8629 eina: protect promise death during callbacks cancel. 2016-06-03 17:00:12 -07:00
Felipe Magno de Almeida cd91b02dd1 eina: Add NULL checks and EINA_MAGIC checks to promises
Add NULL checks and EINA_MAGIC checks that avoid crashing when it
shouldn't.
2016-06-03 20:02:02 -03:00
Felipe Magno de Almeida e79eb53e8d eina: Remove Eina_Promise* parameter in promise callback
Remove not very useful parameter to eina_promise_then callbacks.
2016-06-03 18:15:57 -03:00
Felipe Magno de Almeida 8fec0d5139 eina: Remove unnecessary indirection to promises
Now when dealing with pointer types, we will not get pointer to
pointer semantics in callbacks and eina_promise_owner_value_set
for Eina_Promise.

It will work as expected:

Eina_Promise_Owner* promise = eina_promise_add();

void* p = malloc(sizeof(T));
eina_promise_owner_value_set(promise, p, &free);
2016-06-03 17:22:12 -03:00
Larry Jr 507bbdb054 Eina: Fix eina_promise_all refcount ordering problem
The call to eina_promise_then steals the first ref'count, so it is
possible that the promise is freed after the eina_promise_then,
so we need to eina_promise_ref before eina_promise_then.
2016-06-03 11:19:52 -03:00
Cedric BAIL 9bcad265a7 eina: don't access dead promise.
We do properly unref promise while calling all the then callback. There
is no need to check it a second time (which actually lead to a 100%
bad access).

T3759
2016-05-31 14:59:26 -07:00
Felipe Magno de Almeida b0b8109cd5 eina: Make cancelled promises use EINA_ERROR_PROMISE_CANCELLED error code 2016-05-26 13:35:07 -03:00