This example shows how an \hyperlink{group__Ecore__Job__Group_ga2942e879ec428e9f5156a4ba688217ed}{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 \hyperlink{group__Ecore__Job__Group_ga0fe8d42a1b07963b48d7bb175ee39558}{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}
\textcolor{comment}{//Compile with:}
\textcolor{comment}{// gcc -o ecore\_job\_example ecore\_job\_example.c `pkg-config --libs --cflags ecore`}

\textcolor{preprocessor}{#include <Ecore.h>}
\textcolor{preprocessor}{#include <unistd.h>}

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_job\_print\_cb(\textcolor{keywordtype}{void} *data)
\{
   \textcolor{keywordtype}{char} *str = data;

   printf(\textcolor{stringliteral}{"%s\(\backslash\)n"}, str);
\}

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_job\_quit\_cb(\textcolor{keywordtype}{void} *data EINA\_UNUSED)
\{
   \hyperlink{group__Ecore__Main__Loop__Group_ga95cf8e97dff0716433c2c5474d606a98}{ecore\_main\_loop\_quit}();
\}

\textcolor{keywordtype}{int}
main(\textcolor{keywordtype}{void})
\{
   \hyperlink{group__Ecore__Job__Group_ga2942e879ec428e9f5156a4ba688217ed}{Ecore\_Job} *job1, *job2, *job3, *job\_quit;
   \textcolor{keywordtype}{char} *str1 = \textcolor{stringliteral}{"Job 1 started."};
   \textcolor{keywordtype}{char} *str2 = \textcolor{stringliteral}{"Job 2 started."};
   \textcolor{keywordtype}{char} *str3 = \textcolor{stringliteral}{"Job 3 started."};

   \textcolor{keywordflow}{if} (!\hyperlink{group__Ecore__Init__Group_ga77757609684a2c922dc5ec398274751b}{ecore\_init}())
     \{
        printf(\textcolor{stringliteral}{"ERROR: Cannot init Ecore!\(\backslash\)n"});
        \textcolor{keywordflow}{return} -1;
     \}

   job1 = \hyperlink{group__Ecore__Job__Group_ga0f9f52dc3b3afad5cea1b5924f432b83}{ecore\_job\_add}(\_job\_print\_cb, str1);
   job2 = \hyperlink{group__Ecore__Job__Group_ga0f9f52dc3b3afad5cea1b5924f432b83}{ecore\_job\_add}(\_job\_print\_cb, str2);
   job3 = \hyperlink{group__Ecore__Job__Group_ga0f9f52dc3b3afad5cea1b5924f432b83}{ecore\_job\_add}(\_job\_print\_cb, str3);

   job\_quit = \hyperlink{group__Ecore__Job__Group_ga0f9f52dc3b3afad5cea1b5924f432b83}{ecore\_job\_add}(\_job\_quit\_cb, NULL);

   (void)job1;
   (void)job3;
   (void)job\_quit;

   printf(\textcolor{stringliteral}{"Created jobs 1, 2, 3 and quit.\(\backslash\)n"});

   \textcolor{keywordflow}{if} (job2)
     \{
        \textcolor{keywordtype}{char} *str;
        str = \hyperlink{group__Ecore__Job__Group_ga0fe8d42a1b07963b48d7bb175ee39558}{ecore\_job\_del}(job2);
        job2 = NULL;
        printf(\textcolor{stringliteral}{"Deleted job 2. Its data was: \(\backslash\)"%s\(\backslash\)"\(\backslash\)n"}, str);
     \}

   \hyperlink{group__Ecore__Main__Loop__Group_gaf103b9f668bb3e4fed12e52c6180132d}{ecore\_main\_loop\_begin}();
   \hyperlink{group__Ecore__Init__Group_ga768298b932f18d7e7593a447493e5cde}{ecore\_shutdown}();

   \textcolor{keywordflow}{return} 0;
\}

\end{DoxyCodeInclude}
 