Data Structures | Macros | Typedefs | Functions | Variables
eina_promise.h File Reference

Data Structures

struct  _Eina_Future_Schedule_Entry
 A struct that represents an scheduled event. More...
 
struct  _Eina_Future_Scheduler
 This struct is used as a bridge between Eina and the future scheduler. More...
 
struct  _Eina_Future_Cb_Easy_Desc
 A struct with callbacks to be used by eina_future_cb_easy_from_desc() and eina_future_cb_easy() More...
 
struct  _Eina_Future_Cb_Console_Desc
 A struct used to define the prefix and suffix to be printed along side the a future value. More...
 
struct  _Eina_Future_Cb_Log_Desc
 This struct is used by eina_future_cb_log_from_desc() and its contents will be routed to eina_log_print() along side the future value. More...
 
struct  _Eina_Future_Desc
 A struct used to define a callback and data for a future. More...
 
struct  _Eina_Future_Race_Result
 The struct that is used to store the race result. More...
 

Macros

#define EINA_FUTURE_SENTINEL   ((void *)(unsigned long)-1)
 Used by eina_promise_race_array() and eina_promise_all_array() and friends to flag the end of the array. More...
 
#define eina_promise_race(...)   eina_promise_race_array((Eina_Future *[]){__VA_ARGS__, EINA_FUTURE_SENTINEL})
 A syntactic sugar over eina_promise_race_array(). More...
 
#define eina_future_race(...)   eina_future_race_array((Eina_Future *[]){__VA_ARGS__, EINA_FUTURE_SENTINEL})
 A syntactic sugar over eina_future_race_array(). More...
 
#define eina_future_all(...)   eina_future_all_array((Eina_Future *[]){__VA_ARGS__, EINA_FUTURE_SENTINEL})
 A syntactic sugar over eina_future_all_array(). More...
 
#define eina_promise_all(...)   eina_promise_all_array((Eina_Future *[]){__VA_ARGS__, EINA_FUTURE_SENTINEL})
 A syntactic sugar over eina_promise_all_array(). More...
 
#define eina_future_cb_easy(...)   eina_future_cb_easy_from_desc((Eina_Future_Cb_Easy_Desc){__VA_ARGS__})
 A syntactic sugar over eina_future_cb_easy_from_desc(). More...
 
#define eina_future_chain(_prev, ...)   eina_future_chain_array(_prev, (Eina_Future_Desc[]){__VA_ARGS__, {.cb = NULL, .data = NULL}})
 A syntactic sugar over eina_future_chain_array(). More...
 
#define eina_future_then(_prev, ...)   eina_future_then_from_desc(_prev, (Eina_Future_Desc){__VA_ARGS__})
 A syntactic sugar over eina_future_then_from_desc(). More...
 
#define eina_future_cb_console(...)   eina_future_cb_console_from_desc((Eina_Future_Cb_Console_Desc){__VA_ARGS__})
 A syntactic sugar over eina_future_cb_console_from_desc(). More...
 
#define eina_future_cb_log_dbg(_prefix, _suffix)
 A syntactic sugar over eina_future_cb_log_from_desc(). More...
 
#define eina_future_cb_log_crit(_prefix, _suffix)
 A syntactic sugar over eina_future_cb_log_from_desc(). More...
 
#define eina_future_cb_log_err(_prefix, _suffix)
 A syntactic sugar over eina_future_cb_log_from_desc(). More...
 
#define eina_future_cb_log_info(_prefix, _suffix)
 A syntactic sugar over eina_future_cb_log_from_desc(). More...
 
#define eina_future_cb_log_warn(_prefix, _suffix)
 A syntactic sugar over eina_future_cb_log_from_desc(). More...
 
#define eina_future_then_easy(_prev, ...)   eina_future_then_from_desc(_prev, eina_future_cb_easy(__VA_ARGS__))
 A syntactic sugar over eina_future_then() and eina_future_cb_easy(). More...
 
#define eina_future_chain_easy(_prev, ...)   eina_future_chain_easy_array(_prev, (Eina_Future_Cb_Easy_Desc[]) {__VA_ARGS__, {NULL, NULL, NULL, NULL, NULL}})
 A syntactic sugar over eina_future_chain() and eina_future_cb_easy(). More...
 

Typedefs

typedef struct _Eina_Promise Eina_Promise
 Convenience wrapper.
 
typedef struct _Eina_Future Eina_Future
 Convenience wrapper.
 
typedef struct _Eina_Future_Desc Eina_Future_Desc
 Convenience wrapper over _Eina_Future_Desc.
 
typedef struct _Eina_Future_Race_Result Eina_Future_Race_Result
 Convenience wrapper over _Eina_Future_Race_Result.
 
typedef struct _Eina_Future_Cb_Easy_Desc Eina_Future_Cb_Easy_Desc
 Convenience wrapper over _Eina_Future_Cb_Easy_Desc.
 
typedef struct _Eina_Future_Cb_Console_Desc Eina_Future_Cb_Console_Desc
 Convenience wrapper over _Eina_Future_Cb_Console_Desc.
 
typedef struct _Eina_Future_Scheduler Eina_Future_Scheduler
 Convenience wrapper over _Eina_Future_Scheduler.
 
typedef struct _Eina_Future_Schedule_Entry Eina_Future_Schedule_Entry
 Convenience wrapper over _Eina_Future_Schedule_Entry.
 
typedef struct _Eina_Future_Cb_Log_Desc Eina_Future_Cb_Log_Desc
 Convenience wrapper over _Eina_Future_Cb_Log_Desc.
 
typedef Eina_Value(* Eina_Future_Cb) (void *data, const Eina_Value value, const Eina_Future *dead_future)
 A callback used to inform that a future was resolved. More...
 
typedef void(* Eina_Future_Scheduler_Cb) (Eina_Future *f, Eina_Value value)
 A callback used by the Eina_Future_Scheduler to deliver the future operation result. More...
 
typedef void(* Eina_Promise_Cancel_Cb) (void *data, const Eina_Promise *dead_promise)
 A callback used to inform that a promise was canceled. More...
 
typedef Eina_Value(* Eina_Future_Success_Cb) (void *data, const Eina_Value value)
 A callback used to inform that the future completed with success. More...
 
typedef Eina_Value(* Eina_Future_Error_Cb) (void *data, const Eina_Error error)
 A callback used to inform that the future completed with failure. More...
 
typedef void(* Eina_Future_Free_Cb) (void *data, const Eina_Future *dead_future)
 A callback used to inform that the future was freed and the user should also free the data. More...
 

Functions

EINA_API Eina_Promiseeina_promise_new (Eina_Future_Scheduler *scheduler, Eina_Promise_Cancel_Cb cancel_cb, const void *data)
 Creates a new promise. More...
 
EINA_API Eina_Promiseeina_promise_continue_new (const Eina_Future *dead_future, Eina_Promise_Cancel_Cb cancel_cb, const void *data)
 Creates a new promise from a dead_future. More...
 
EINA_API void eina_promise_resolve (Eina_Promise *p, Eina_Value value)
 Resolves a promise. More...
 
EINA_API void eina_promise_reject (Eina_Promise *p, Eina_Error err)
 Rejects a promise. More...
 
EINA_API void eina_future_cancel (Eina_Future *f)
 Cancels a future. More...
 
EINA_API void eina_future_desc_flush (Eina_Future_Desc *desc)
 Flushes an Eina_Future_Desc. More...
 
EINA_API void eina_future_cb_easy_desc_flush (Eina_Future_Cb_Easy_Desc *desc)
 Flushes an Eina_Future_Cb_Easy_Desc. More...
 
EINA_API Eina_Value eina_promise_as_value (Eina_Promise *p)
 Creates a new Eina_Value from a promise. More...
 
EINA_API Eina_Value eina_future_as_value (Eina_Future *f)
 Creates an Eina_Value from a future. More...
 
EINA_API Eina_Futureeina_future_new (Eina_Promise *p)
 Creates a new future. More...
 
EINA_API Eina_Futureeina_future_resolved (Eina_Future_Scheduler *scheduler, Eina_Value value)
 Creates a new future that is already resolved to a value. More...
 
EINA_API Eina_Futureeina_future_rejected (Eina_Future_Scheduler *scheduler, Eina_Error err)
 Creates a new future that is already rejected to a specified error. More...
 
EINA_API Eina_Futureeina_future_then_from_desc (Eina_Future *prev, const Eina_Future_Desc desc)
 Register an Eina_Future_Desc to be used when the future is resolved/rejected. More...
 
EINA_API Eina_Future_Desc eina_future_cb_log_from_desc (const Eina_Future_Cb_Log_Desc desc)
 Creates an Eina_Future_Desc that will log the previous future resolved value. More...
 
EINA_API Eina_Futureeina_future_chain_array (Eina_Future *prev, const Eina_Future_Desc descs[])
 Creates a future chain. More...
 
EINA_API Eina_Futureeina_future_chain_easy_array (Eina_Future *prev, const Eina_Future_Cb_Easy_Desc descs[])
 Wrapper around eina_future_chain_array() and eina_future_cb_easy_from_desc() More...
 
EINA_API Eina_Future_Desc eina_future_cb_console_from_desc (const Eina_Future_Cb_Console_Desc desc)
 Creates an Eina_Future_Desc that will print the previous future's resolved value. More...
 
EINA_API Eina_Future_Desc eina_future_cb_ignore_error (Eina_Error err)
 Returns an Eina_Future_Desc that ignores an error. More...
 
EINA_API Eina_Future_Desc eina_future_cb_convert_to (const Eina_Value_Type *type)
 Creates an Eina_Future_Desc which will convert the received eina value to a given type. More...
 
EINA_API Eina_Future_Desc eina_future_cb_easy_from_desc (const Eina_Future_Cb_Easy_Desc desc)
 Creates an Eina_Future_Desc based on an Eina_Future_Cb_Easy_Desc. More...
 
EINA_API Eina_Promiseeina_promise_all_array (Eina_Future *array[])
 Creates an all promise. More...
 
EINA_API Eina_Promiseeina_promise_all_iterator (Eina_Iterator *iterator)
 Creates an all promise from an iterator. More...
 
EINA_API Eina_Promiseeina_promise_race_array (Eina_Future *array[])
 Creates a race promise. More...
 
static Eina_Futureeina_future_all_array (Eina_Future *array[])
 Creates a future that will be resolved once all futures from array is resolved. More...
 
static Eina_Futureeina_future_all_iterator (Eina_Iterator *iterator)
 Creates a future that will be resolved once all futures from iterator are resolved. More...
 
static Eina_Futureeina_future_race_array (Eina_Future *array[])
 Creates a future that will be resolved once a future array is resolved. More...
 

Variables

EINA_API const Eina_Value_Type EINA_VALUE_TYPE_PROMISE
 Value type for Eina_Value's containing an Eina_Promise.
 
EINA_API const Eina_Value_Struct_DescEINA_PROMISE_RACE_STRUCT_DESC
 A pointer to the race struct description, which is used by eina_promise_race_array(). More...