\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{structEina__Promise}{Eina\+\_\+\+Promise}} $\ast$ \mbox{\hyperlink{group__Eina__Promise_gae2c735463cbd7321dbff1f9def0a6957}{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{structEina__Promise}{Eina\+\_\+\+Promise}} $\ast$ \mbox{\hyperlink{group__Eina__Promise_gae8498626ef81d2608761cee80409fe03}{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 
void \mbox{\hyperlink{group__Eina__Promise_gab5d3ac1b6d4e58a1da5d9e14b77f4c97}{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 
void \mbox{\hyperlink{group__Eina__Promise_ga215b6ba47e18087e2bd99b87312ff393}{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_ga979033926fa12396c080db78bbbe13e9}\label{group__Eina__Promise_ga979033926fa12396c080db78bbbe13e9}} 
const \mbox{\hyperlink{group__Eina__Value__Group_gaab67ab8bcd0624280c5276044b07e0d2}{Eina\+\_\+\+Value\+\_\+\+Type}} \mbox{\hyperlink{group__Eina__Promise_ga979033926fa12396c080db78bbbe13e9}{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_gaba2b599c7aabe3ab664dc3d47f62a33a}{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{   \mbox{\hyperlink{group__Eina__Value__Value__Group_gab5c6558b1b8be2ad597d71a765cbf5f6}{eina\_value\_setup}}(\&v, \mbox{\hyperlink{group__Eina__Value__Group_ga916f76c8d5ffd4c3ee3c322a54efd0b7}{EINA\_VALUE\_TYPE\_STRING}});}
\DoxyCodeLine{   \mbox{\hyperlink{group__Eina__Value__Value__Group_ga9a1407c953694c3d6f40ab01ebe9a294}{eina\_value\_set}}(\&v, \textcolor{stringliteral}{"{}Promise resolved"{}});}
\DoxyCodeLine{   \mbox{\hyperlink{group__Eina__Promise_gab5d3ac1b6d4e58a1da5d9e14b77f4c97}{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_ga7b9cb9d24ecebfdbb957436e2e669402}{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_gae2c735463cbd7321dbff1f9def0a6957}{eina\_promise\_new}}(scheduler, \_promise\_cancel, ctx);}
\DoxyCodeLine{   \textcolor{keywordflow}{return} ctx-\/>p;}
\DoxyCodeLine{\}}

\end{DoxyCode}
 

\doxysubsection{Function Documentation}
\mbox{\Hypertarget{group__Eina__Promise_gae2c735463cbd7321dbff1f9def0a6957}\label{group__Eina__Promise_gae2c735463cbd7321dbff1f9def0a6957}} 
\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{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_gaf4fee59b5faafd33965969ac35377cee}{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_ga6d7a6889b5f1a9fca02f868c484148e7}{eina\_future\_cancel}}(\mbox{\hyperlink{group__Eina__Future_gaf4fee59b5faafd33965969ac35377cee}{eina\_future\_new}}(\mbox{\hyperlink{group__Eina__Promise_gae2c735463cbd7321dbff1f9def0a6957}{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_ga6d7a6889b5f1a9fca02f868c484148e7}{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_gad2e4b9d0ff885ccc38cd2319d05a7274}{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_ga6d7a6889b5f1a9fca02f868c484148e7}{eina\+\_\+future\+\_\+cancel()}} 

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

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

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

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

\mbox{\hyperlink{group__Eina__Future_ga6151e485fad1e3623c365d11e319d7da}{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 DBG, eina\+\_\+mempool\+\_\+calloc(), EINA\+\_\+\+SAFETY\+\_\+\+ON\+\_\+\+NULL\+\_\+\+RETURN\+\_\+\+VAL, \+\_\+\+Eina\+\_\+\+Future\+\_\+\+Scheduler\+::recall, and \+\_\+\+Eina\+\_\+\+Future\+\_\+\+Scheduler\+::schedule.



Referenced by eina\+\_\+future\+\_\+as\+\_\+value(), eina\+\_\+future\+\_\+rejected(), eina\+\_\+future\+\_\+resolved(), and eina\+\_\+promise\+\_\+all\+\_\+iterator().

\mbox{\Hypertarget{group__Eina__Promise_gae8498626ef81d2608761cee80409fe03}\label{group__Eina__Promise_gae8498626ef81d2608761cee80409fe03}} 
\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{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_ga6151e485fad1e3623c365d11e319d7da}{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_ga6d7a6889b5f1a9fca02f868c484148e7}{eina\_future\_cancel}}(\mbox{\hyperlink{group__Eina__Future_gaf4fee59b5faafd33965969ac35377cee}{eina\_future\_new}}(\mbox{\hyperlink{group__Eina__Promise_gae2c735463cbd7321dbff1f9def0a6957}{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_ga6d7a6889b5f1a9fca02f868c484148e7}{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_gae8498626ef81d2608761cee80409fe03}{eina\_promise\_continue\_new}}(dead\_future, \_promise\_cancel, NULL);}
\DoxyCodeLine{   \textcolor{keywordflow}{return} \mbox{\hyperlink{group__Eina__Future_ga6151e485fad1e3623c365d11e319d7da}{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_gad2e4b9d0ff885ccc38cd2319d05a7274}{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_ga6d7a6889b5f1a9fca02f868c484148e7}{eina\+\_\+future\+\_\+cancel()}} 

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

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

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

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

\mbox{\hyperlink{group__Eina__Future_ga6151e485fad1e3623c365d11e319d7da}{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 DBG, eina\+\_\+mempool\+\_\+calloc(), EINA\+\_\+\+SAFETY\+\_\+\+ON\+\_\+\+NULL\+\_\+\+RETURN\+\_\+\+VAL, and EINA\+\_\+\+SAFETY\+\_\+\+ON\+\_\+\+TRUE\+\_\+\+RETURN\+\_\+\+VAL.

\mbox{\Hypertarget{group__Eina__Promise_gab5d3ac1b6d4e58a1da5d9e14b77f4c97}\label{group__Eina__Promise_gab5d3ac1b6d4e58a1da5d9e14b77f4c97}} 
\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 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 \mbox{\hyperlink{group__Eina__Value__Value__Group_ga940660709a2862bafac92f47bb721a68}{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_gae2c735463cbd7321dbff1f9def0a6957}{eina\+\_\+promise\+\_\+new()}} 

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

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


References eina\+\_\+value\+\_\+flush().



Referenced by eina\+\_\+future\+\_\+resolved().

\mbox{\Hypertarget{group__Eina__Promise_ga215b6ba47e18087e2bd99b87312ff393}\label{group__Eina__Promise_ga215b6ba47e18087e2bd99b87312ff393}} 
\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 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_gace284ef9f3063e831b66f04638c7f465}{EINA\+\_\+\+VALUE\+\_\+\+TYPE\+\_\+\+ERROR}}.
\end{DoxyNote}
\begin{DoxySeeAlso}{See also}
\mbox{\hyperlink{group__Eina__Promise_gae2c735463cbd7321dbff1f9def0a6957}{eina\+\_\+promise\+\_\+new()}} 

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

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


References DBG, eina\+\_\+error\+\_\+msg\+\_\+get(), EINA\+\_\+\+SAFETY\+\_\+\+ON\+\_\+\+FALSE\+\_\+\+GOTO, eina\+\_\+value\+\_\+flush(), eina\+\_\+value\+\_\+set(), eina\+\_\+value\+\_\+setup(), and EINA\+\_\+\+VALUE\+\_\+\+TYPE\+\_\+\+ERROR.



Referenced by eina\+\_\+future\+\_\+rejected().

