hey Cedric, I think things got a bit more complex than they should:

On Thu, Jan 11, 2018 at 12:16 AM, Cedric BAIL <[email protected]> wrote:

>  static void
> -_eina_promise_value_steal_and_link(Eina_Value value, Eina_Future *f)
> +_eina_promise_value_steal_and_link(Eina_Future_Scheduler *scheduler,
> +                                   Eina_Value value,
> +                                   Eina_Future *f)
>  {
>     Eina_Promise *p = _eina_value_promise_steal(&value);
>     DBG("Promise %p stolen from value", p);
>     eina_value_flush(&value);
> +   // In the case of continue promise, define a scheduler when steal&link
> +   if (!p->scheduler) p->scheduler = scheduler;

these shouldn't need to change at all, just the creation of promise
based on dead_future, by checking the scheduler that called the future
callback.

see below:
[...]

> +EAPI Eina_Promise *
> +eina_promise_continue_new(const Eina_Future *dead_future,
> +                          Eina_Promise_Cancel_Cb cancel_cb, const void *data)
> +{
> +   EINA_SAFETY_ON_NULL_RETURN_VAL(cancel_cb, NULL);
> +   EINA_SAFETY_ON_NULL_RETURN_VAL(dead_future, NULL);

you should be able to check if the pointer is still alive in the
mempool here, otherwise things may crash (if it's a real DEAD future
;-))

EINA_FUTURE_CHECK_GOTO(dead_future, label)


> +   EINA_SAFETY_ON_TRUE_RETURN_VAL(dead_future->scheduled_entry != NULL, 
> NULL);
> +   EINA_SAFETY_ON_TRUE_RETURN_VAL(dead_future->promise != NULL, NULL);
> +
> +   Eina_Promise *p = eina_mempool_calloc(_promise_mp, sizeof(Eina_Promise));
> +   EINA_SAFETY_ON_NULL_RETURN_VAL(p, NULL);
> +   p->cancel = cancel_cb;
> +   p->data = data;
> +   p->scheduler = NULL;

I don't get this... you were suppose to get the p->scheduler from
dead_future, no?

do this by changing _scheduled_entry_cb() so
dead_future->scheduled_entry is NOT nullified before calling the
future, then you can get:

   p->scheduler = dead_future->scheduled_entry->scheduler;

and keep everything else the same.

eina_future_cancel() should NOT be affected, since it's guarded
against errors with EINA_FUTURE_CHECK_RETURN(), that checks for f->cb
== EINA_FUTURE_DISPATCHED, and this is marked before calling back in
_eina_future_cb_dispatch().


> + * Eina_Value
> + * _future_resolve(void *data, const Eina_Value v, const Eina_Future 
> *dead_future)
> + * {
> + *    Eina_Promise *p;
> + *    p = eina_promise_continue_new(dead_future, _promise_cancel, NULL);
> + *    return eina_promise_as_value(p);
> + * }
> + * @endcode
> + *
> + * If you already have a value and want to create a future that will
> + * resolve to it directly use the eina_future_resolved(), it has the
> + * same effect as creating a promise and immediately resolving it.

this comment is confusing here. If you have a value resolved, just
RETURN it in this future... it's automatically handled to be
dispatched from a clean context.



-- 
Gustavo Sverzut Barbieri
--------------------------------------
Mobile: +55 (16) 99354-9890

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
enlightenment-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel

Reply via email to