On Tue, 31 May 2016 17:01:40 -0700 Cedric BAIL <[email protected]> said:
> On Tue, May 31, 2016 at 4:45 PM, Carsten Haitzler <[email protected]> > wrote: > > On Tue, 31 May 2016 06:15:29 -0700 Cedric BAIL <[email protected]> said: > > > >> On May 30, 2016 22:51, "Carsten Haitzler" <[email protected]> wrote: > >> > > >> > the api for promises seems pretty confusing. just look at this: > >> > > >> > job = efl_loop_job(obj, args); > >> > eina_promise_then(job, _efl_loop_args_job_cb, NULL, args); > >> > > >> > why do i need to pass in args... TWICE? well ok - this specific way of > >> using > >> > promises for jobs... both promises in efl_loop.eo do this, and it's > >> confusing. > >> > the void *data when creating the job (first args) is not used at all. the > >> data > >> > for the promise is passed as data to the promise callback. > >> > > >> > why do this? value isn't used here in the promise -actually it's the > >> promise > >> > ptr itself for whatever reason. > >> > >> They are both different. A promise deliver a value at some point in the > >> future to multiple callback couple. The data you give when creating the > >> promise is the one delivered in the future. The one you pass with your > >> couple of callbacks is obviously tied to that couple of callback. They are > >> clearly 2 different things. Obviously you don't need to pass any data at > >> all in both case. > > > > ummm the void *data when creating the job never is passed as anything to > > promise callbacks. why have it at all? it's misleading. it's useless. i sat > > down and had to figure out what is and isn't passed because it was entirely > > unclear what was passed or not. value is the promise. i've printfed it's > > values trying to figure out what gets passed where. bizarre that it is but > > whatever. but data from the job is unused. data from the eina_promise_then > > is used and passed as data to the cb's > > It is passed as the value void * pointer. The second parameter of the > function being called by the then case. You did set it to EINA_UNUSED > in your case. it isn't passed to value. i printf'd value as %p, not the data * in the job. that's my point. it's all confusing. rename it to void *value then to at least make that obvious. make sure the docs say that. they do not. they say it's passed as data ptr. here is the output of this code: static void _efl_loop_args_job_cb(void *data, void *value, Eina_Promise *promise EINA_UNUSED) { Efl_Loop_Args *args = data; Eo *obj = eo_parent_get(args); printf("promise cb: data = %p, value = %p, promise = %p\n", data, value, promise); eo_event_callback_call(obj, EFL_LOOP_EVENT_ARGS, args); eo_unref(args); // FIXME: probably eo_del() } EOLIAN static void _efl_loop_args_add(Eo *obj, Efl_Loop_Data *pd EINA_UNUSED, int argc, const char **argv) { Eina_Promise *job; Efl_Loop_Args *args = eo_add(EFL_LOOP_ARGS_CLASS, obj); if (!args) return; efl_loop_args_set(args, argc, argv); job = efl_loop_job(obj, (void *)0x1); printf("efl_loop_job() return = %p\n", job); printf("data ptr for promise = %p\n", args); eina_promise_then(job, _efl_loop_args_job_cb, NULL, args); } output: efl_loop_job() return = 0x11efcc8 data ptr for promise = 0x4000000200000021 promise cb: data = 0x4000000200000021, value = 0x11efd70, promise = 0x11efcc8 value is NOT the data passed into job. not at all. i passed in 0x1. the documentation says: @in data: const(void)* @optional; [[The data to be given when the promise is done.]] ? the data to be given to promise. there is only one data parameter - the first. the docs SAY it's given to the promise. that's not the case. it's not given to value OR to data. if you mean that value POINTS to a void * containing the value of data above.. then say that. :) but this is totally not portable. i just say - remove the void * for the job. same for timeout too - it's not portable and the documentation is confusing as it claims to be data where it's actually value... and value actually is a pointer TO the pointer you provide. > -- > Cedric BAIL > -- ------------- Codito, ergo sum - "I code, therefore I am" -------------- The Rasterman (Carsten Haitzler) [email protected] ------------------------------------------------------------------------------ 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. https://ad.doubleclick.net/ddm/clk/305295220;132659582;e _______________________________________________ enlightenment-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/enlightenment-devel
