> -------- Original Message -------- > Subject: [E-devel] Proposal: automatic Event->Promise/Future > Local Time: September 5, 2017 6:20 AM > UTC Time: September 5, 2017 1:20 PM > From: [email protected] > To: edevel <[email protected]> > > In many cases we use events as a single shot event, then we > efl_event_callback_add(), wait for the callback, then > efl_event_callback_del()... > > With the introduction of Promise/Future pair it would be nice to have > that automated, for example Efl.Io.Copier produces an event "done". > Most of the times when you"re using Efl.Io.Copier you only want to > know when it was finished or when it produced an error (event: > "error"). > > Then it would improve usability to do something like: > > Eina_Future *f = efl_future_event(copier, > EFL_IO_COPIER_EVENT_DONE, /* success event */ > EFL_IO_COPIER_EVENT_ERROR); /* error event */ > eina_future_chain(f, do_something, do_something_else, on_error); > > and all would be handled for you: add/del callbacks, resolve the > promise and all.
Just a potential idea here, why not reverse the problem. Instead of implementing this future on top of this events, why not have a future and have this events automatically create a future when someone register a callback on it. This avoid completely the problem of dealing with the void* and seems really simple to me. > This is doable, EXCEPT events are "void *" and may go away when the > event callback returns. However eina_promise_resolve() will postpone > the future chain to another mainloop iteration -- thus needs a COPY. > How to copy "void *"? Filling the Eina_Value_Type from the eolian type seems quite complex to me. It would require to give a function to do the copy and destruction of the structure in eolian most likely. Also I am not sure it would work in all case, some object that we put in the structure are really build to only be alive for the duration of the callback (I am thinking about input event here). Cedric ------------------------------------------------------------------------------ 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
