This example shows how an \mbox{\hyperlink{group__Ecore__Job__Group_ga51a4bfa938b1205aead7d0dd2dae83db}{Ecore\+\_\+\+Job}} can be added, how it can be deleted, and that they always execute in the added order.

First, 2 callback functions are declared, one that prints strings passed to it in the {\ttfamily data} pointer, and another one that quits the main loop. In the {\ttfamily main} function, 3 jobs are added using the first callback, and another one is added using the second one.

Then the second added job is deleted just to demonstrate the usage of \mbox{\hyperlink{group__Ecore__Job__Group_ga6baa274d218948aaaeaaa19cd8b094f4}{ecore\+\_\+job\+\_\+del()}}, and the main loop is finally started. Run this example to see that {\ttfamily job1}, {\ttfamily job3} and {\ttfamily job\+\_\+quit} are ran, in this order.


\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{\textcolor{comment}{//Compile with:}}
\DoxyCodeLine{\textcolor{comment}{// gcc -\/o ecore\_job\_example ecore\_job\_example.c `pkg-\/config -\/-\/libs -\/-\/cflags ecore`}}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{preprocessor}{\#include <Ecore.h>}}
\DoxyCodeLine{\textcolor{preprocessor}{\#include <unistd.h>}}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{keyword}{static} \textcolor{keywordtype}{void}}
\DoxyCodeLine{\_job\_print\_cb(\textcolor{keywordtype}{void} *data)}
\DoxyCodeLine{\{}
\DoxyCodeLine{   \textcolor{keywordtype}{char} *str = data;}
\DoxyCodeLine{}
\DoxyCodeLine{   printf(\textcolor{stringliteral}{"{}\%s\(\backslash\)n"{}}, str);}
\DoxyCodeLine{\}}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{keyword}{static} \textcolor{keywordtype}{void}}
\DoxyCodeLine{\_job\_quit\_cb(\textcolor{keywordtype}{void} *data \mbox{\hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}})}
\DoxyCodeLine{\{}
\DoxyCodeLine{   \mbox{\hyperlink{group__Ecore__Main__Loop__Group_ga95cf8e97dff0716433c2c5474d606a98}{ecore\_main\_loop\_quit}}();}
\DoxyCodeLine{\}}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{keywordtype}{int}}
\DoxyCodeLine{main(\textcolor{keywordtype}{void})}
\DoxyCodeLine{\{}
\DoxyCodeLine{   \mbox{\hyperlink{group__Ecore__Job__Group_ga51a4bfa938b1205aead7d0dd2dae83db}{Ecore\_Job}} *job1, *job2, *job3, *job\_quit;}
\DoxyCodeLine{   \textcolor{keywordtype}{char} *str1 = \textcolor{stringliteral}{"{}Job 1 started."{}};}
\DoxyCodeLine{   \textcolor{keywordtype}{char} *str2 = \textcolor{stringliteral}{"{}Job 2 started."{}};}
\DoxyCodeLine{   \textcolor{keywordtype}{char} *str3 = \textcolor{stringliteral}{"{}Job 3 started."{}};}
\DoxyCodeLine{}
\DoxyCodeLine{   \textcolor{keywordflow}{if} (!\mbox{\hyperlink{group__Ecore__Init__Group_ga77757609684a2c922dc5ec398274751b}{ecore\_init}}())}
\DoxyCodeLine{     \{}
\DoxyCodeLine{        printf(\textcolor{stringliteral}{"{}ERROR: Cannot init Ecore!\(\backslash\)n"{}});}
\DoxyCodeLine{        \textcolor{keywordflow}{return} -\/1;}
\DoxyCodeLine{     \}}
\DoxyCodeLine{}
\DoxyCodeLine{   job1 = \mbox{\hyperlink{group__Ecore__Job__Group_ga859b3807977b215b7589f5b61dbf9ac2}{ecore\_job\_add}}(\_job\_print\_cb, str1);}
\DoxyCodeLine{   job2 = \mbox{\hyperlink{group__Ecore__Job__Group_ga859b3807977b215b7589f5b61dbf9ac2}{ecore\_job\_add}}(\_job\_print\_cb, str2);}
\DoxyCodeLine{   job3 = \mbox{\hyperlink{group__Ecore__Job__Group_ga859b3807977b215b7589f5b61dbf9ac2}{ecore\_job\_add}}(\_job\_print\_cb, str3);}
\DoxyCodeLine{}
\DoxyCodeLine{   job\_quit = \mbox{\hyperlink{group__Ecore__Job__Group_ga859b3807977b215b7589f5b61dbf9ac2}{ecore\_job\_add}}(\_job\_quit\_cb, NULL);}
\DoxyCodeLine{}
\DoxyCodeLine{   (void)job1;}
\DoxyCodeLine{   (void)job3;}
\DoxyCodeLine{   (void)job\_quit;}
\DoxyCodeLine{}
\DoxyCodeLine{   printf(\textcolor{stringliteral}{"{}Created jobs 1, 2, 3 and quit.\(\backslash\)n"{}});}
\DoxyCodeLine{}
\DoxyCodeLine{   \textcolor{keywordflow}{if} (job2)}
\DoxyCodeLine{     \{}
\DoxyCodeLine{        \textcolor{keywordtype}{char} *str;}
\DoxyCodeLine{        str = \mbox{\hyperlink{group__Ecore__Job__Group_ga6baa274d218948aaaeaaa19cd8b094f4}{ecore\_job\_del}}(job2);}
\DoxyCodeLine{        job2 = NULL;}
\DoxyCodeLine{        printf(\textcolor{stringliteral}{"{}Deleted job 2. Its data was: \(\backslash\)"{}\%s\(\backslash\)"{}\(\backslash\)n"{}}, str);}
\DoxyCodeLine{     \}}
\DoxyCodeLine{}
\DoxyCodeLine{   \mbox{\hyperlink{group__Ecore__Main__Loop__Group_gaf103b9f668bb3e4fed12e52c6180132d}{ecore\_main\_loop\_begin}}();}
\DoxyCodeLine{   \mbox{\hyperlink{group__Ecore__Init__Group_ga768298b932f18d7e7593a447493e5cde}{ecore\_shutdown}}();}
\DoxyCodeLine{}
\DoxyCodeLine{   \textcolor{keywordflow}{return} 0;}
\DoxyCodeLine{\}}
\DoxyCodeLine{}

\end{DoxyCodeInclude}
 