Hi all, As some may have followed at IRC, ProFUSION embedded systems dedicate some effort to make a new, simpler, leaner and easier Future and Promise implementation.
If you're new to Promise and Future, want to know what problems it solve and how our design looks, please read https://phab.enlightenment.org/w/future_promise/ (which I just updated, then if you read it before, do it again). Our engineer, Guilherme Iscaro, worked for weeks and more than 10 interactions to deliver the code at https://phab.enlightenment.org/D5131, which I kindly ask for you to review and test. I plan to merge this on Monday night if nothing big shows. What makes us happy is that the core is very lean on memory and simple. So easy that it could be moved to Eina, solving the old implementation issue where promise was implemented in one library while Future was in another -- They also involved Eo, which is way heavier than our new implementation which is only 16 bytes per Promise and 28 bytes per Future (32bits). With some macros with could deliver some syntax sugar to eliminate functions with half dozen "NULL" pointers. Even better one can also provide "named" parameters using the structure members. Previously ignored and now handled is the type of the result. Before the function would get a pointer to the value and would need to know how to interpret it, trusting it's the expected type and how to release the memory was mostly undefined, particularly with chaining and conversion. Eina_Value is used to carry type information with the actual value, providing many benefits: - runtime type checking - provides information how to release memory (eina_value_flush) - provides information how to copy memory (eina_value_copy) - provides conversion to other types, like to string (eina_value_to_string) - extensible, one can provide new Eina_Value_Type in their own code/library - can be passed on the stack and returned as value, avoid memory allocations and programming errors. There is a drawback: it's recommended to always check value.type prior to use eina_value_get(), some utilities are provided to help with basic types. C++ should provide some templates to help with such mundane tasks. In C11 we could use _Generic() to provide something similar. This email is already long enough, please check the Wiki for motivation, details and examples. https://phab.enlightenment.org/w/future_promise/ Please review the code before Monday night, when I plan to merge this. https://phab.enlightenment.org/D5131 Cheers, -- 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 enlightenment-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-devel