ecore: introduce efl_loop_promise_new to simplify creation of Eina_Promise.

This commit is contained in:
Cedric BAIL 2018-01-03 12:12:48 -08:00
parent 5efb8f3eb2
commit 5628ecddd6
2 changed files with 20 additions and 0 deletions

View File

@ -70,6 +70,19 @@ EAPI int efl_loop_exit_code_process(Eina_Value *value);
*/
EAPI Eina_Future_Scheduler *efl_loop_future_scheduler_get(const Eo *obj);
/**
* @brief Create a future attached to the current loop
*
* @param[in] An object which will provide a loop, either by being a loop or a loop consumer
* @param cancel_cb A callback used to inform that the promise was canceled. Use
* this callback to @c free @p data. @p cancel_cb must not be @c NULL !
* @param data Data to @p cancel_cb.
* @return A promise or @c NULL on error.
*
* @see eina_promise_new()
*/
EAPI Eina_Promise *efl_loop_promise_new(const Eo *obj, Eina_Promise_Cancel_Cb cancel_cb, const void *data);
#include "efl_loop_fd.eo.h"
#include "efl_loop_handler.eo.h"

View File

@ -741,4 +741,11 @@ efl_loop_future_scheduler_get(const Eo *obj)
#define EFL_LOOP_EXTRA_OPS \
EFL_OBJECT_OP_FUNC(efl_loop_message_process, _efl_loop_message_process)
EAPI Eina_Promise *
efl_loop_promise_new(const Eo *obj, Eina_Promise_Cancel_Cb cancel_cb, const void *data)
{
return eina_promise_new(efl_loop_future_scheduler_get(obj),
cancel_cb, data);
}
#include "efl_loop.eo.c"