On Thu, Jun 16, 2016 at 11:13 AM, Tom Hacohen <[email protected]> wrote: > On 03/06/16 20:17, Cedric BAIL wrote: > <snip> >>>> also promises should become eo objects with event cb's >>>> so they work just like everything else. i can ref, unref, delete and >>>> whatever >>>> them like everything else. >> >> As said above, this does work. Example with event : >> eo_promise = efl_file_set(image, "toto.jpg", NULL); >> eo_event_callback_array_add(eo_promise, promise_callbacks1(), NULL); >> eo_event_callback_array_add(eo_promise, promise_callbacks2(), NULL); >> >> In this 3 lines, there is already 2 case in which that fail. First if, >> the object is done before the callback is set, data are lost and there >> is no way to get any event. Ofcourse, we can override the behavior of >> events on this eo_promise completely. Now let's imagine, that we >> actually do always store the events, so that everytime someone >> register a callback we can send the event. Still you can't auto del >> the object at any point in time, you have to force the user to >> implement the eo_del and to always provide both a then and cancel >> callback. >> >> Other possibility, it is an event on the object itself. >> eo_event_callback_array_add(image, promise_callbacks1(), NULL); >> efl_file_set(image, "toto.jpg", NULL); >> eo_event_callback_array_add(image, promise_callbacks2(), NULL); >> >> Same again, this can not work. The first group of event handler, >> promise_callbacks1(), may actually be triggered by a previously >> running promise on the object, so you have to first forcefully stop >> the previous operation. This would add complexity. And still the >> second callback has the same issue as the previous case, if it is a >> normal eo event, it could have been triggered before any callback get >> registered and the event be lost... Same story short, doesn't work. >> > > I'm currently reading through the thread, and I didn't see anything > mentioned about this other than a casual remark you made, so just wanted > to make it crystal clear regarding implementing it as an Eo object. > The whole point/magic of inheritance is that you can and are supposed to > override functions if needed. Overriding callback add to call the > callback immediately upon addition (if already done) is how I would > implement promise callbacks. It's clean, easy and as intended. This is > definitely not a problem.
I hope that by the end of this thread you do understand why this doesn't work. Basically the point is that you don't have to eo_del a promise ever. Once you set the callback on it and when all the expected callback are called, the promise vanish. Inheritance on callback, that is a given, thanks. Now, how do you make sure you have all the callback registered and that you have delivered the value to everyone that expect it before the promise commit succide ? -- Cedric BAIL ------------------------------------------------------------------------------ What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic patterns at an interface-level. Reveals which users, apps, and protocols are consuming the most bandwidth. Provides multi-vendor support for NetFlow, J-Flow, sFlow and other flows. Make informed decisions using capacity planning reports. http://sdm.link/zohomanageengine _______________________________________________ enlightenment-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/enlightenment-devel
