_Eina_Future_Desc Struct Reference

- Main Page
- Related Pages
- Modules
- Data Structures
- Files
- Examples

- Data Structures
- Data Structure Index
- Class Hierarchy
- Data Fields

Data Fields
_Eina_Future_Desc Struct Reference
Eina » Eina Promises » Eina Futures

A struct used to define a callback and data for a future. More...

`#include <eina_promise.h>`

## Data Fields
Eina_Future_Cb | cb
| Called when the future is resolved or rejected.
const void * | data
| Context data to `cb`.
Eina_Future ** | storage
| The storage will be used by Eina to store a pointer to the created future.

## Detailed Description

A struct used to define a callback and data for a future.

This struct contains a future completion callback and a data to the future completion callback which is used by eina_future_then(), eina_future_chain() and friends to inform the user about the future result. The _Eina_Future_Desc::data variable should be freed when _Eina_Future_Desc::cb is called, otherwise it will leak.

Note
  If eina_future_then(), eina_future_chain() and friends fails to return a valid future (in other words: `NULL` is returned) the _Eina_Future_Desc::cb will be called report an error like `EINVAL` or `ENOMEM` so _Eina_Future_Desc::data can be freed.

See also
  eina_future_then()
  eina_future_chain_array()
  eina_future_cb_convert_to()
  eina_future_cb_console_from_desc()
  eina_future_cb_ignore_error()
  eina_future_cb_easy_from_desc()
  eina_future_cb_log_from_desc()

## Field Documentation

## ◆ cb

Eina_Future_Cb _Eina_Future_Desc::cb

Called when the future is resolved or rejected.

Once a future is resolved or rejected this function is called passing the future result to inform the user that the future operation has ended. Normally this function is called from a safe context (main loop or some platform defined safe context), however in case of a future cancellation (eina_future_cancel()) or if eina_future_then(), eina_future_chain() and friends fails to create a new future, this function is called from the current context.

Use this function to free `data` if necessary.

See also
  eina_future_chain()
  eina_future_then()
  eina_future_cancel()

Referenced by eina_future_cb_console_from_desc(), eina_future_cb_convert_to(), eina_future_chain_array(), and eina_future_new().

## ◆ data

const void* _Eina_Future_Desc::data

Context data to `cb`.

The `data` should be freed inside `cb`, otherwise its memory will leak!

Referenced by eina_future_cb_console_from_desc().

## ◆ storage

Eina_Future** _Eina_Future_Desc::storage

The storage will be used by Eina to store a pointer to the created future.

It can be `NULL`.