\hypertarget{group__Eina__Promise}{}\doxysection{Eina Promises}
\label{group__Eina__Promise}\index{Eina Promises@{Eina Promises}}


Promises are a programming paradigm that simplifies synchronization when concurrent execution is present.  


\doxysubsection*{Modules}
\begin{DoxyCompactItemize}
\item 
\mbox{\hyperlink{group__Eina__Future}{Eina Futures}}
\begin{DoxyCompactList}\small\item\em Methods and structures dealing with \mbox{\hyperlink{structEina__Future}{Eina\+\_\+\+Future}}. \end{DoxyCompactList}\end{DoxyCompactItemize}
\doxysubsection*{Data Structures}
\begin{DoxyCompactItemize}
\item 
struct \mbox{\hyperlink{structEina__Promise}{Eina\+\_\+\+Promise}}
\begin{DoxyCompactList}\small\item\em An opaque structure representing a piece of data that will be available at a later point. \end{DoxyCompactList}\end{DoxyCompactItemize}
\doxysubsection*{Functions}
\begin{DoxyCompactItemize}
\item 
\mbox{\hyperlink{group__Eina__Types__Group_ga6ac08753ba12bc9c7a0390cf67868f4f}{EINA\+\_\+\+API}} \mbox{\hyperlink{structEina__Promise}{Eina\+\_\+\+Promise}} $\ast$ \mbox{\hyperlink{group__Eina__Promise_gaabcdc9f302644a86f2cca80e3a0fb049}{eina\+\_\+promise\+\_\+new}} (\mbox{\hyperlink{group__Eina__Future__Callbacks_ga190fb0e75b86d093db85b05abfd21ebd}{Eina\+\_\+\+Future\+\_\+\+Scheduler}} $\ast$scheduler, \mbox{\hyperlink{group__Eina__Future__Callbacks_gab618b4d7aef449893108219332d8a85e}{Eina\+\_\+\+Promise\+\_\+\+Cancel\+\_\+\+Cb}} cancel\+\_\+cb, const void $\ast$data)
\begin{DoxyCompactList}\small\item\em Creates a new promise. \end{DoxyCompactList}\item 
\mbox{\hyperlink{group__Eina__Types__Group_ga6ac08753ba12bc9c7a0390cf67868f4f}{EINA\+\_\+\+API}} \mbox{\hyperlink{structEina__Promise}{Eina\+\_\+\+Promise}} $\ast$ \mbox{\hyperlink{group__Eina__Promise_ga85eef01166d4d3938ba7363718d8192b}{eina\+\_\+promise\+\_\+continue\+\_\+new}} (const \mbox{\hyperlink{structEina__Future}{Eina\+\_\+\+Future}} $\ast$dead\+\_\+future, \mbox{\hyperlink{group__Eina__Future__Callbacks_gab618b4d7aef449893108219332d8a85e}{Eina\+\_\+\+Promise\+\_\+\+Cancel\+\_\+\+Cb}} cancel\+\_\+cb, const void $\ast$data)
\begin{DoxyCompactList}\small\item\em Creates a new promise from a dead\+\_\+future. \end{DoxyCompactList}\item 
\mbox{\hyperlink{group__Eina__Types__Group_ga6ac08753ba12bc9c7a0390cf67868f4f}{EINA\+\_\+\+API}} void \mbox{\hyperlink{group__Eina__Promise_ga231f1e09741f0cb0e9ceeef15cf4e4ee}{eina\+\_\+promise\+\_\+resolve}} (\mbox{\hyperlink{structEina__Promise}{Eina\+\_\+\+Promise}} $\ast$p, \mbox{\hyperlink{group__Eina__Value__Group_ga7985e8af6e956ae31b381bf829173cc0}{Eina\+\_\+\+Value}} value)
\begin{DoxyCompactList}\small\item\em Resolves a promise. \end{DoxyCompactList}\item 
\mbox{\hyperlink{group__Eina__Types__Group_ga6ac08753ba12bc9c7a0390cf67868f4f}{EINA\+\_\+\+API}} void \mbox{\hyperlink{group__Eina__Promise_ga33c04f489c071e795839cbf6e60566ba}{eina\+\_\+promise\+\_\+reject}} (\mbox{\hyperlink{structEina__Promise}{Eina\+\_\+\+Promise}} $\ast$p, \mbox{\hyperlink{group__Eina__Error__Group_ga95b3cbb33e987e7d92a81ea785001686}{Eina\+\_\+\+Error}} err)
\begin{DoxyCompactList}\small\item\em Rejects a promise. \end{DoxyCompactList}\end{DoxyCompactItemize}
\doxysubsection*{Variables}
\begin{DoxyCompactItemize}
\item 
\mbox{\Hypertarget{group__Eina__Promise_ga20f8b1103ee569060834d1dc3ab5f401}\label{group__Eina__Promise_ga20f8b1103ee569060834d1dc3ab5f401}} 
\mbox{\hyperlink{group__Eina__Types__Group_ga6ac08753ba12bc9c7a0390cf67868f4f}{EINA\+\_\+\+API}} const \mbox{\hyperlink{group__Eina__Value__Group_gaab67ab8bcd0624280c5276044b07e0d2}{Eina\+\_\+\+Value\+\_\+\+Type}} {\bfseries EINA\+\_\+\+VALUE\+\_\+\+TYPE\+\_\+\+PROMISE}
\begin{DoxyCompactList}\small\item\em Value type for \mbox{\hyperlink{group__Eina__Value__Group_ga7985e8af6e956ae31b381bf829173cc0}{Eina\+\_\+\+Value}}\textquotesingle{}s containing an \mbox{\hyperlink{structEina__Promise}{Eina\+\_\+\+Promise}}. \end{DoxyCompactList}\end{DoxyCompactItemize}


\doxysubsection{Detailed Description}
Promises are a programming paradigm that simplifies synchronization when concurrent execution is present. 

Since C does not natively support Promises the Eina library provides the \mbox{\hyperlink{structEina__Promise}{Eina\+\_\+\+Promise}} and \mbox{\hyperlink{structEina__Future}{Eina\+\_\+\+Future}} objects.

In procedural languages like C if you need a value which is not yet available, for instance because it takes a long time to calculate or has to be fetched from a remote server, you typically have to wait.

Other languages however can return a Promise and continue execution immediately. A promise acts as a placeholder for the requested value\+: the value is not available yet but will be at some point in the future.

With a promise in hand you can attach callbacks to be triggered when the value becomes available (i.\+e. when the promise is fulfilled) and then continue your calculations. You can even pass the promise to other methods which will then be executed as values become available, forming complex chains.

An \mbox{\hyperlink{structEina__Promise}{Eina\+\_\+\+Promise}} can be considered as an object with the sole purpose of emitting the \char`\"{}\+Promise Resolved\char`\"{} event. \mbox{\hyperlink{structEina__Future}{Eina\+\_\+\+Future}} are callbacks attached to this object to be called when the event is emitted. The promised value is passed to the callbacks whenever it\textquotesingle{}s available.

Here\textquotesingle{}s a typical example\+:


\begin{DoxyCode}{0}
\DoxyCodeLine{\textcolor{preprocessor}{\#include\ <Ecore.h>}}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{keyword}{static}\ \textcolor{keywordtype}{void}}
\DoxyCodeLine{\_promise\_cancel(\textcolor{keywordtype}{void}\ *data,\ \mbox{\hyperlink{structEina__Promise}{Eina\_Promise}}\ *p\ \mbox{\hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}})}
\DoxyCodeLine{\{}
\DoxyCodeLine{\ \ Ctx\ *ctx\ =\ data;}
\DoxyCodeLine{\ \ \textcolor{comment}{//\ In\ case\ the\ promise\ is\ canceled\ we\ must\ stop\ the\ timer!}}
\DoxyCodeLine{\ \ \mbox{\hyperlink{group__Ecore__Timer__Group_ga7c118b6a6d232b63a6500e599d2a1b47}{ecore\_timer\_del}}(ctx-\/>timer);}
\DoxyCodeLine{\ \ free(ctx);}
\DoxyCodeLine{\}}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{keyword}{static}\ \mbox{\hyperlink{group__Eina__Types__Group_ga3fe0caf72e93b1bab1ca8ee3ccf3f226}{Eina\_Bool}}}
\DoxyCodeLine{\_promise\_resolve(\textcolor{keywordtype}{void}\ *data)}
\DoxyCodeLine{\{}
\DoxyCodeLine{\ \ \ Ctx\ *ctx\ =\ data;}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{struct__Eina__Value}{Eina\_Value}}\ v;}
\DoxyCodeLine{\ \ \ eina\_value\_setup(\&v,\ \mbox{\hyperlink{group__Eina__Value__Group_ga916f76c8d5ffd4c3ee3c322a54efd0b7}{EINA\_VALUE\_TYPE\_STRING}});}
\DoxyCodeLine{\ \ \ eina\_value\_set(\&v,\ \textcolor{stringliteral}{"{}Promise\ resolved"{}});}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Eina__Promise_ga231f1e09741f0cb0e9ceeef15cf4e4ee}{eina\_promise\_resolve}}(ctx-\/>p,\ v);}
\DoxyCodeLine{\ \ \ free(ctx);}
\DoxyCodeLine{\ \ \ \textcolor{keywordflow}{return}\ \mbox{\hyperlink{group__Eina__Types__Group_ga1feb115f8e9913e806e090d9bd5a7301}{EINA\_FALSE}};}
\DoxyCodeLine{\}}
\DoxyCodeLine{}
\DoxyCodeLine{\mbox{\hyperlink{structEina__Promise}{Eina\_Promise}}\ *}
\DoxyCodeLine{promise\_create(\mbox{\hyperlink{struct__Eina__Future__Scheduler}{Eina\_Future\_Scheduler}}\ *scheduler)}
\DoxyCodeLine{\{}
\DoxyCodeLine{\ \ \ Ctx\ *ctx\ =\ malloc(\textcolor{keyword}{sizeof}(Ctx));}
\DoxyCodeLine{\ \ \ \textcolor{comment}{//\ A\ timer\ is\ scheduled\ in\ order\ to\ resolve\ the\ promise}}
\DoxyCodeLine{\ \ \ ctx-\/>timer\ =\ \mbox{\hyperlink{group__Ecore__Timer__Group_ga926423e464d7ef71105dd822d90e1187}{ecore\_timer\_add}}(122,\ \_promise\_resolve,\ ctx);}
\DoxyCodeLine{\ \ \ \textcolor{comment}{//\ The\ \_promise\_cancel()\ will\ be\ used\ to\ clean\ ctx\ if\ the\ promise\ is\ canceled.}}
\DoxyCodeLine{\ \ \ ctx-\/>p\ =\ \mbox{\hyperlink{group__Eina__Promise_gaabcdc9f302644a86f2cca80e3a0fb049}{eina\_promise\_new}}(scheduler,\ \_promise\_cancel,\ ctx);}
\DoxyCodeLine{\ \ \ \textcolor{keywordflow}{return}\ ctx-\/>p;}
\DoxyCodeLine{\}}

\end{DoxyCode}
 

\doxysubsection{Function Documentation}
\mbox{\Hypertarget{group__Eina__Promise_gaabcdc9f302644a86f2cca80e3a0fb049}\label{group__Eina__Promise_gaabcdc9f302644a86f2cca80e3a0fb049}} 
\index{Eina Promises@{Eina Promises}!eina\_promise\_new@{eina\_promise\_new}}
\index{eina\_promise\_new@{eina\_promise\_new}!Eina Promises@{Eina Promises}}
\doxysubsubsection{\texorpdfstring{eina\_promise\_new()}{eina\_promise\_new()}}
{\footnotesize\ttfamily \mbox{\hyperlink{group__Eina__Types__Group_ga6ac08753ba12bc9c7a0390cf67868f4f}{EINA\+\_\+\+API}} \mbox{\hyperlink{structEina__Promise}{Eina\+\_\+\+Promise}} $\ast$ eina\+\_\+promise\+\_\+new (\begin{DoxyParamCaption}\item[{\mbox{\hyperlink{group__Eina__Future__Callbacks_ga190fb0e75b86d093db85b05abfd21ebd}{Eina\+\_\+\+Future\+\_\+\+Scheduler}} $\ast$}]{scheduler,  }\item[{\mbox{\hyperlink{group__Eina__Future__Callbacks_gab618b4d7aef449893108219332d8a85e}{Eina\+\_\+\+Promise\+\_\+\+Cancel\+\_\+\+Cb}}}]{cancel\+\_\+cb,  }\item[{const void $\ast$}]{data }\end{DoxyParamCaption})}



Creates a new promise. 

This function creates a new promise which can be used to create a future using \mbox{\hyperlink{group__Eina__Future_ga6c6d97b2f3be307cc43364d6f4aade48}{eina\+\_\+future\+\_\+new()}}. Every time a promise is created an \mbox{\hyperlink{group__Eina__Future__Callbacks_gab618b4d7aef449893108219332d8a85e}{Eina\+\_\+\+Promise\+\_\+\+Cancel\+\_\+\+Cb}} must be provided which is used to free resources that were created.

A promise may be canceled directly by calling\+: 
\begin{DoxyCode}{0}
\DoxyCodeLine{\mbox{\hyperlink{group__Eina__Future_ga5462a38eabc060b163d24c9d7395ae3b}{eina\_future\_cancel}}(\mbox{\hyperlink{group__Eina__Future_ga6c6d97b2f3be307cc43364d6f4aade48}{eina\_future\_new}}(\mbox{\hyperlink{group__Eina__Promise_gaabcdc9f302644a86f2cca80e3a0fb049}{eina\_promise\_new}}(...)))}

\end{DoxyCode}
 That is, canceling any future that is chained to receive the results.

However promises can be canceled indirectly by other entities. These other entities will call \mbox{\hyperlink{group__Eina__Future_ga5462a38eabc060b163d24c9d7395ae3b}{eina\+\_\+future\+\_\+cancel()}} themselves, however you may not be aware of that. Some common sources of indirect cancellations\+:

\begin{DoxyItemize}
\item A subsystem was shutdown, canceling all pending futures (i.\+e.\+: \mbox{\hyperlink{group__Ecore__Init__Group_ga768298b932f18d7e7593a447493e5cde}{ecore\+\_\+shutdown()}})\end{DoxyItemize}
\begin{DoxyItemize}
\item An EO object was linked to the promise or future, then if the object dies (last reference is gone), then the pending promises and futures will be canceled.\end{DoxyItemize}
\begin{DoxyItemize}
\item Some other entity (library provider or library user) chained and canceled his future, which will result in your future being canceled.\end{DoxyItemize}
Since a promise may be canceled indirectly (by code sections that goes beyond your scope) you should always provide a cancel callback, even if you think you\textquotesingle{}ll not need it.

If you already have a value and want to create a future that will resolve to it directly use the \mbox{\hyperlink{group__Eina__Future_ga9098beb0b805b06856008968a5b7c14a}{eina\+\_\+future\+\_\+resolved()}}, it has the same effect as creating a promise and immediately resolving it.


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in,out}}  & {\em scheduler} & The scheduler. \\
\hline
\mbox{\texttt{ in}}  & {\em cancel\+\_\+cb} & A callback used to inform that the promise was canceled. Use this callback to {\ttfamily free} {\ttfamily data}. {\ttfamily cancel\+\_\+cb} must not be {\ttfamily NULL} ! \\
\hline
\mbox{\texttt{ in}}  & {\em data} & Data to {\ttfamily cancel\+\_\+cb}. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
A promise or {\ttfamily NULL} on error. 
\end{DoxyReturn}
\begin{DoxySeeAlso}{See also}
\mbox{\hyperlink{group__Eina__Future_ga5462a38eabc060b163d24c9d7395ae3b}{eina\+\_\+future\+\_\+cancel()}} 

\mbox{\hyperlink{group__Eina__Future_ga6c6d97b2f3be307cc43364d6f4aade48}{eina\+\_\+future\+\_\+new()}} 

\mbox{\hyperlink{group__Eina__Promise_ga85eef01166d4d3938ba7363718d8192b}{eina\+\_\+promise\+\_\+continue\+\_\+new()}} 

\mbox{\hyperlink{group__Eina__Promise_ga231f1e09741f0cb0e9ceeef15cf4e4ee}{eina\+\_\+promise\+\_\+resolve()}} 

\mbox{\hyperlink{group__Eina__Promise_ga33c04f489c071e795839cbf6e60566ba}{eina\+\_\+promise\+\_\+reject()}} 

\mbox{\hyperlink{group__Eina__Future_gab966fb4259f6c1d0f18840e31213a26a}{eina\+\_\+promise\+\_\+as\+\_\+value()}} 

\mbox{\hyperlink{group__Eina__Future__Callbacks_ga190fb0e75b86d093db85b05abfd21ebd}{Eina\+\_\+\+Future\+\_\+\+Scheduler}} 

\mbox{\hyperlink{group__Eina__Future__Callbacks_ga8ecbf4d4816b354fad992cd5874c656a}{Eina\+\_\+\+Future\+\_\+\+Schedule\+\_\+\+Entry}} 

\mbox{\hyperlink{group__Eina__Future__Callbacks_gac685b488df7948131b6405451d0b4fb5}{Eina\+\_\+\+Future\+\_\+\+Scheduler\+\_\+\+Cb}} 
\end{DoxySeeAlso}


References \mbox{\hyperlink{group__Eina__Safety__Checks__Group_gab2b07061fc6500dedd9cd41c8d16f95d}{EINA\+\_\+\+SAFETY\+\_\+\+ON\+\_\+\+NULL\+\_\+\+RETURN\+\_\+\+VAL}}, \mbox{\hyperlink{struct__Eina__Future__Scheduler_ad7e267c5652f88e78c3d1c4ac82d1e09}{\+\_\+\+Eina\+\_\+\+Future\+\_\+\+Scheduler\+::recall}}, and \mbox{\hyperlink{struct__Eina__Future__Scheduler_ad57b2e01e8ba4bd0e2f339fe81573d84}{\+\_\+\+Eina\+\_\+\+Future\+\_\+\+Scheduler\+::schedule}}.



Referenced by \mbox{\hyperlink{group__Eina__Future_ga59277c714beab7a5231f014d4eed2670}{eina\+\_\+future\+\_\+as\+\_\+value()}}, \mbox{\hyperlink{group__Eina__Future_ga5f603578d333ca9f9c435785efa8cdcd}{eina\+\_\+future\+\_\+rejected()}}, \mbox{\hyperlink{group__Eina__Future_ga9098beb0b805b06856008968a5b7c14a}{eina\+\_\+future\+\_\+resolved()}}, and \mbox{\hyperlink{group__Eina__Future_gad86937f4354573d8e13cbe6ec62d0869}{eina\+\_\+promise\+\_\+all\+\_\+iterator()}}.

\mbox{\Hypertarget{group__Eina__Promise_ga85eef01166d4d3938ba7363718d8192b}\label{group__Eina__Promise_ga85eef01166d4d3938ba7363718d8192b}} 
\index{Eina Promises@{Eina Promises}!eina\_promise\_continue\_new@{eina\_promise\_continue\_new}}
\index{eina\_promise\_continue\_new@{eina\_promise\_continue\_new}!Eina Promises@{Eina Promises}}
\doxysubsubsection{\texorpdfstring{eina\_promise\_continue\_new()}{eina\_promise\_continue\_new()}}
{\footnotesize\ttfamily \mbox{\hyperlink{group__Eina__Types__Group_ga6ac08753ba12bc9c7a0390cf67868f4f}{EINA\+\_\+\+API}} \mbox{\hyperlink{structEina__Promise}{Eina\+\_\+\+Promise}} $\ast$ eina\+\_\+promise\+\_\+continue\+\_\+new (\begin{DoxyParamCaption}\item[{const \mbox{\hyperlink{structEina__Future}{Eina\+\_\+\+Future}} $\ast$}]{dead\+\_\+future,  }\item[{\mbox{\hyperlink{group__Eina__Future__Callbacks_gab618b4d7aef449893108219332d8a85e}{Eina\+\_\+\+Promise\+\_\+\+Cancel\+\_\+\+Cb}}}]{cancel\+\_\+cb,  }\item[{const void $\ast$}]{data }\end{DoxyParamCaption})}



Creates a new promise from a dead\+\_\+future. 

This function creates a new promise from a future currently being resolved which can be used to create a \mbox{\hyperlink{group__Eina__Value__Group_ga7985e8af6e956ae31b381bf829173cc0}{Eina\+\_\+\+Value}} with \mbox{\hyperlink{group__Eina__Future_gab966fb4259f6c1d0f18840e31213a26a}{eina\+\_\+promise\+\_\+as\+\_\+value()}}. Every time a promise is created an \mbox{\hyperlink{group__Eina__Future__Callbacks_gab618b4d7aef449893108219332d8a85e}{Eina\+\_\+\+Promise\+\_\+\+Cancel\+\_\+\+Cb}} must be provided which is used to free resources that were created.

A promise may be canceled directly by calling\+: 
\begin{DoxyCode}{0}
\DoxyCodeLine{\mbox{\hyperlink{group__Eina__Future_ga5462a38eabc060b163d24c9d7395ae3b}{eina\_future\_cancel}}(\mbox{\hyperlink{group__Eina__Future_ga6c6d97b2f3be307cc43364d6f4aade48}{eina\_future\_new}}(\mbox{\hyperlink{group__Eina__Promise_gaabcdc9f302644a86f2cca80e3a0fb049}{eina\_promise\_new}}(...)))}

\end{DoxyCode}
 That is, canceling any future that is chained to receive the results.

However promises can be canceled indirectly by other entities. These other entities will call \mbox{\hyperlink{group__Eina__Future_ga5462a38eabc060b163d24c9d7395ae3b}{eina\+\_\+future\+\_\+cancel()}} themselves, however you may not be aware of that. Some common sources of indirect cancellations\+:

\begin{DoxyItemize}
\item A subsystem was shutdown, canceling all pending futures (i.\+e.\+: \mbox{\hyperlink{group__Ecore__Init__Group_ga768298b932f18d7e7593a447493e5cde}{ecore\+\_\+shutdown()}})\end{DoxyItemize}
\begin{DoxyItemize}
\item An EO object was linked to the promise or future, then if the object dies (last reference is gone), then the pending promises and futures will be canceled.\end{DoxyItemize}
\begin{DoxyItemize}
\item Some other entity (library provider or library user) chained and canceled his future, which will result in your future being canceled.\end{DoxyItemize}
Since a promise may be canceled indirectly (by code sections that goes beyond your scope) you should always provide a cancel callback, even if you think you\textquotesingle{}ll not need it.

Here\textquotesingle{}s a typical example\+:


\begin{DoxyCode}{0}
\DoxyCodeLine{\mbox{\hyperlink{struct__Eina__Value}{Eina\_Value}}}
\DoxyCodeLine{\_future\_resolve(\textcolor{keywordtype}{void}\ *data,\ \textcolor{keyword}{const}\ \mbox{\hyperlink{struct__Eina__Value}{Eina\_Value}}\ v,\ \textcolor{keyword}{const}\ \mbox{\hyperlink{structEina__Future}{Eina\_Future}}\ *dead\_future)}
\DoxyCodeLine{\{}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{structEina__Promise}{Eina\_Promise}}\ *p;}
\DoxyCodeLine{\ \ \ p\ =\ \mbox{\hyperlink{group__Eina__Promise_ga85eef01166d4d3938ba7363718d8192b}{eina\_promise\_continue\_new}}(dead\_future,\ \_promise\_cancel,\ NULL);}
\DoxyCodeLine{\ \ \ \textcolor{keywordflow}{return}\ \mbox{\hyperlink{group__Eina__Future_gab966fb4259f6c1d0f18840e31213a26a}{eina\_promise\_as\_value}}(p);}
\DoxyCodeLine{\}}

\end{DoxyCode}


If you already have a value and want to create a future that will resolve to it directly use the \mbox{\hyperlink{group__Eina__Future_ga9098beb0b805b06856008968a5b7c14a}{eina\+\_\+future\+\_\+resolved()}}, it has the same effect as creating a promise and immediately resolving it.

\begin{DoxyNote}{Note}
This function is to be used solely inside of a future resolve callback with the \mbox{\hyperlink{group__Eina__Value__Group_ga7985e8af6e956ae31b381bf829173cc0}{Eina\+\_\+\+Value}} being returned from it.
\end{DoxyNote}

\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em dead\+\_\+future} & The future being resolved to get a scheduler from. \\
\hline
\mbox{\texttt{ in}}  & {\em cancel\+\_\+cb} & A callback used to inform that the promise was canceled. Use this callback to {\ttfamily free} {\ttfamily data}. {\ttfamily cancel\+\_\+cb} must not be {\ttfamily NULL}. \\
\hline
\mbox{\texttt{ in}}  & {\em data} & Data to {\ttfamily cancel\+\_\+cb}. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
A promise or {\ttfamily NULL} on error. 
\end{DoxyReturn}
\begin{DoxySeeAlso}{See also}
\mbox{\hyperlink{group__Eina__Future_ga5462a38eabc060b163d24c9d7395ae3b}{eina\+\_\+future\+\_\+cancel()}} 

\mbox{\hyperlink{group__Eina__Future_ga6c6d97b2f3be307cc43364d6f4aade48}{eina\+\_\+future\+\_\+new()}} 

\mbox{\hyperlink{group__Eina__Promise_gaabcdc9f302644a86f2cca80e3a0fb049}{eina\+\_\+promise\+\_\+new()}} 

\mbox{\hyperlink{group__Eina__Promise_ga231f1e09741f0cb0e9ceeef15cf4e4ee}{eina\+\_\+promise\+\_\+resolve()}} 

\mbox{\hyperlink{group__Eina__Promise_ga33c04f489c071e795839cbf6e60566ba}{eina\+\_\+promise\+\_\+reject()}} 

\mbox{\hyperlink{group__Eina__Future_gab966fb4259f6c1d0f18840e31213a26a}{eina\+\_\+promise\+\_\+as\+\_\+value()}} 

\mbox{\hyperlink{group__Eina__Future__Callbacks_ga190fb0e75b86d093db85b05abfd21ebd}{Eina\+\_\+\+Future\+\_\+\+Scheduler}} 

\mbox{\hyperlink{group__Eina__Future__Callbacks_ga8ecbf4d4816b354fad992cd5874c656a}{Eina\+\_\+\+Future\+\_\+\+Schedule\+\_\+\+Entry}} 

\mbox{\hyperlink{group__Eina__Future__Callbacks_gac685b488df7948131b6405451d0b4fb5}{Eina\+\_\+\+Future\+\_\+\+Scheduler\+\_\+\+Cb}} 
\end{DoxySeeAlso}


References \mbox{\hyperlink{group__Eina__Safety__Checks__Group_gab2b07061fc6500dedd9cd41c8d16f95d}{EINA\+\_\+\+SAFETY\+\_\+\+ON\+\_\+\+NULL\+\_\+\+RETURN\+\_\+\+VAL}}, and \mbox{\hyperlink{group__Eina__Safety__Checks__Group_ga1dbe0d7e3c6b10f4bd49a2a132d73269}{EINA\+\_\+\+SAFETY\+\_\+\+ON\+\_\+\+TRUE\+\_\+\+RETURN\+\_\+\+VAL}}.

\mbox{\Hypertarget{group__Eina__Promise_ga231f1e09741f0cb0e9ceeef15cf4e4ee}\label{group__Eina__Promise_ga231f1e09741f0cb0e9ceeef15cf4e4ee}} 
\index{Eina Promises@{Eina Promises}!eina\_promise\_resolve@{eina\_promise\_resolve}}
\index{eina\_promise\_resolve@{eina\_promise\_resolve}!Eina Promises@{Eina Promises}}
\doxysubsubsection{\texorpdfstring{eina\_promise\_resolve()}{eina\_promise\_resolve()}}
{\footnotesize\ttfamily \mbox{\hyperlink{group__Eina__Types__Group_ga6ac08753ba12bc9c7a0390cf67868f4f}{EINA\+\_\+\+API}} void eina\+\_\+promise\+\_\+resolve (\begin{DoxyParamCaption}\item[{\mbox{\hyperlink{structEina__Promise}{Eina\+\_\+\+Promise}} $\ast$}]{p,  }\item[{\mbox{\hyperlink{group__Eina__Value__Group_ga7985e8af6e956ae31b381bf829173cc0}{Eina\+\_\+\+Value}}}]{value }\end{DoxyParamCaption})}



Resolves a promise. 

This function schedules a resolve event in a safe context (main loop or some platform defined safe context), whenever possible the future callbacks will be dispatched.


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in,out}}  & {\em p} & A promise to resolve. \\
\hline
\mbox{\texttt{ in}}  & {\em value} & The value to be delivered.\\
\hline
\end{DoxyParams}
Note that the {\ttfamily value} contents must survive this function scope, that is, do {\bfseries{not}} use stack allocated blobs, arrays, structures or types that keep references to memory you give. Values will be automatically cleaned up using {\ttfamily eina\+\_\+value\+\_\+flush()} once they are unused (no more future or futures returned a new value).

\begin{DoxySeeAlso}{See also}
\mbox{\hyperlink{group__Eina__Promise_gaabcdc9f302644a86f2cca80e3a0fb049}{eina\+\_\+promise\+\_\+new()}} 

\mbox{\hyperlink{group__Eina__Promise_ga33c04f489c071e795839cbf6e60566ba}{eina\+\_\+promise\+\_\+reject()}} 

\mbox{\hyperlink{group__Eina__Future_gab966fb4259f6c1d0f18840e31213a26a}{eina\+\_\+promise\+\_\+as\+\_\+value()}} 
\end{DoxySeeAlso}


Referenced by \mbox{\hyperlink{group__Eina__Future_ga9098beb0b805b06856008968a5b7c14a}{eina\+\_\+future\+\_\+resolved()}}.

\mbox{\Hypertarget{group__Eina__Promise_ga33c04f489c071e795839cbf6e60566ba}\label{group__Eina__Promise_ga33c04f489c071e795839cbf6e60566ba}} 
\index{Eina Promises@{Eina Promises}!eina\_promise\_reject@{eina\_promise\_reject}}
\index{eina\_promise\_reject@{eina\_promise\_reject}!Eina Promises@{Eina Promises}}
\doxysubsubsection{\texorpdfstring{eina\_promise\_reject()}{eina\_promise\_reject()}}
{\footnotesize\ttfamily \mbox{\hyperlink{group__Eina__Types__Group_ga6ac08753ba12bc9c7a0390cf67868f4f}{EINA\+\_\+\+API}} void eina\+\_\+promise\+\_\+reject (\begin{DoxyParamCaption}\item[{\mbox{\hyperlink{structEina__Promise}{Eina\+\_\+\+Promise}} $\ast$}]{p,  }\item[{\mbox{\hyperlink{group__Eina__Error__Group_ga95b3cbb33e987e7d92a81ea785001686}{Eina\+\_\+\+Error}}}]{err }\end{DoxyParamCaption})}



Rejects a promise. 

This function schedules a reject event in a safe context (main loop or some platform defined safe context), whenever possible the future callbacks will be dispatched.


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in,out}}  & {\em p} & A promise to reject. \\
\hline
\mbox{\texttt{ in}}  & {\em err} & An Eina\+\_\+\+Error value \\
\hline
\end{DoxyParams}
\begin{DoxyNote}{Note}
Internally this function will create an \mbox{\hyperlink{group__Eina__Value__Group_ga7985e8af6e956ae31b381bf829173cc0}{Eina\+\_\+\+Value}} with type \mbox{\hyperlink{group__Eina__Value__Group_ga28f6fb160baf3068e7c67ffba0a29c20}{EINA\+\_\+\+VALUE\+\_\+\+TYPE\+\_\+\+ERROR}}.
\end{DoxyNote}
\begin{DoxySeeAlso}{See also}
\mbox{\hyperlink{group__Eina__Promise_gaabcdc9f302644a86f2cca80e3a0fb049}{eina\+\_\+promise\+\_\+new()}} 

\mbox{\hyperlink{group__Eina__Promise_ga231f1e09741f0cb0e9ceeef15cf4e4ee}{eina\+\_\+promise\+\_\+resolve()}} 

\mbox{\hyperlink{group__Eina__Future_gab966fb4259f6c1d0f18840e31213a26a}{eina\+\_\+promise\+\_\+as\+\_\+value()}} 
\end{DoxySeeAlso}


References \mbox{\hyperlink{group__Eina__Error__Group_gac420af42486bcbb879c4be67eacc6c2a}{eina\+\_\+error\+\_\+msg\+\_\+get()}}, \mbox{\hyperlink{group__Eina__Safety__Checks__Group_gafa24bc421bcbbf70e5512619863fb3fc}{EINA\+\_\+\+SAFETY\+\_\+\+ON\+\_\+\+FALSE\+\_\+\+GOTO}}, and \mbox{\hyperlink{group__Eina__Value__Group_ga28f6fb160baf3068e7c67ffba0a29c20}{EINA\+\_\+\+VALUE\+\_\+\+TYPE\+\_\+\+ERROR}}.



Referenced by \mbox{\hyperlink{group__Eina__Future_ga5f603578d333ca9f9c435785efa8cdcd}{eina\+\_\+future\+\_\+rejected()}}.

