Page MenuHomePhabricator

Fix eina promise data store
Open, HighPublic

Description

Eina promise data store is not clean on who own the data that is stored in. It is also not following the usual pattern in the rest of our API that take a string for key. I think we should change the function to :

eina_promise_data_set(promise, key, data, free_cb);
eina_promise_data_get(promise, key);

The data passed at creation time would only be accessible by the creator of the callback as this will be the only time you can actually set it.

cedric created this task.Fri, Dec 28, 9:42 AM
cedric triaged this task as High priority.

so basically a convention of namespacing the string so people only mess with "their data" right? for example the efl loop promise might use "_efl/loop.promise" or something right? this does fix the need for eina_promise_data_set_cb_set()

what you propose does solve this problem. i don't imagine there being that many keys on a promise where this becomes a memory or speed issue. often 0, 1 or maybe 2, on the odd day 3 items.

this also avoids the need for the other function i had to add: eina_promise_data_free_cb_set_cb_set() as the free cb goes with the data and the key.

so i guess i like the idea. solves the problem and isn't that ugly/nasty when it comes to memory and/or performance.

unlike other uses, eina promise is single-owned, short lived, specific purpose.

I don't see any advantage to allow multiple key-value entries... actually once we even thought about not having the data_set, leaving it to be given at creation time... but then some races appear and we used like it's now.

That's another way to fix it, remove all data_set and rely on having an additional future set on the returned future. It might work too. Will investigate that way.

zmike edited projects, added efl: data types, efl (efl-1.22); removed efl, Restricted Project.Tue, Jan 15, 5:57 AM