Data Fields
_Eina_Future_Cb_Easy_Desc Struct Reference

A struct with callbacks to be used by eina_future_cb_easy_from_desc() and eina_future_cb_easy() More...

#include <eina_promise.h>

Data Fields

Eina_Future_Success_Cb success
 Called on success (value.type is not EINA_VALUE_TYPE_ERROR). More...
 
Eina_Future_Error_Cb error
 Called on error (value.type is EINA_VALUE_TYPE_ERROR). More...
 
Eina_Future_Free_Cb free
 Called on all situations to notify future destruction. More...
 
const Eina_Value_Typesuccess_type
 If provided, then success will only be called if the value type matches the given pointer. More...
 
const void * data
 Context data given to every callback. More...
 

Detailed Description

A struct with callbacks to be used by eina_future_cb_easy_from_desc() and eina_future_cb_easy()

See also
eina_future_cb_easy_from_desc()
eina_future_cb_easy()

Field Documentation

◆ success

Eina_Future_Success_Cb _Eina_Future_Cb_Easy_Desc::success

Called on success (value.type is not EINA_VALUE_TYPE_ERROR).

if success_type is not NULL, then the value is guaranteed to be of that type, if it's not, then it will trigger error with EINVAL.

After this function returns, free callback is called if provided.

Referenced by eina_future_chain_easy_array().

◆ error

Eina_Future_Error_Cb _Eina_Future_Cb_Easy_Desc::error

Called on error (value.type is EINA_VALUE_TYPE_ERROR).

This function can return another error, propagating or converting it. However it may also return a non-error, in this case the next future in chain will receive a regular value, which may call its success.

If this function is not provided, then it will passthrough the error to the next error handler.

It may be called with EINVAL if success_type is provided and doesn't match the received type.

It may be called with ECANCELED if future was canceled.

It may be called with ENOMEM if memory allocation failed during callback creation.

After this function returns, free callback is called if provided.

Referenced by eina_future_cb_easy_desc_flush(), and eina_future_chain_easy_array().

◆ free

Eina_Future_Free_Cb _Eina_Future_Cb_Easy_Desc::free

Called on all situations to notify future destruction.

This is called after success or error, as well as it's called if none of them are provided. Thus can be used as a "weak ref" mechanism.

Referenced by eina_future_cb_easy_desc_flush(), and eina_future_chain_easy_array().

◆ success_type

const Eina_Value_Type* _Eina_Future_Cb_Easy_Desc::success_type

If provided, then success will only be called if the value type matches the given pointer.

If provided and doesn't match, then error will be called with EINVAL. If no error, then it will be propagated to the next future in the chain.

Referenced by eina_future_chain_easy_array().

◆ data

const void* _Eina_Future_Cb_Easy_Desc::data

Context data given to every callback.

This must be freed only by free callback as it's called from every case, otherwise it may lead to memory leaks.

Referenced by eina_future_cb_easy_desc_flush().