\hypertarget{ecore_poller_example_8c-example}{}\doxysection{ecore\+\_\+poller\+\_\+example.\+c}
This example shows how to setup and use a poller. See \mbox{\hyperlink{ecore_poller_example_c}{the explanation here}}.


\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{\textcolor{comment}{//Compile with:}}
\DoxyCodeLine{\textcolor{comment}{// gcc -\/o ecore\_poller\_example ecore\_poller\_example.c `pkg-\/config -\/-\/libs -\/-\/cflags ecore eo`}}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{preprocessor}{\#include <Ecore.h>}}
\DoxyCodeLine{\textcolor{comment}{//\#include <Ecore\_Eo.h>}}
\DoxyCodeLine{\textcolor{preprocessor}{\#include <unistd.h>}}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{keyword}{static} \textcolor{keywordtype}{double} \_initial\_time = 0;}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{keyword}{static} \mbox{\hyperlink{group__Eina__Types__Group_ga3fe0caf72e93b1bab1ca8ee3ccf3f226}{Eina\_Bool}}}
\DoxyCodeLine{\_poller\_print\_cb(\textcolor{keywordtype}{void} *data)}
\DoxyCodeLine{\{}
\DoxyCodeLine{   \textcolor{keywordtype}{char} *str = data;}
\DoxyCodeLine{   printf(\textcolor{stringliteral}{"Ecore Poller '\%s' callback called after \%0.3f seconds.\(\backslash\)n"},}
\DoxyCodeLine{          str, \mbox{\hyperlink{group__Ecore__Time__Group_ga98f2439b5d3e7114a75bfe2f0c22c4e9}{ecore\_time\_get}}() -\/ \_initial\_time);}
\DoxyCodeLine{}
\DoxyCodeLine{   \textcolor{keywordflow}{return} \mbox{\hyperlink{group__Ecore__Main__Loop__Group_ga1ee9db07f9a46a8b20fb83e1c6dbed09}{ECORE\_CALLBACK\_RENEW}};}
\DoxyCodeLine{\}}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{keyword}{static} \mbox{\hyperlink{group__Eina__Types__Group_ga3fe0caf72e93b1bab1ca8ee3ccf3f226}{Eina\_Bool}}}
\DoxyCodeLine{\_poller\_quit\_cb(\textcolor{keywordtype}{void} *data \mbox{\hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}})}
\DoxyCodeLine{\{}
\DoxyCodeLine{}
\DoxyCodeLine{   \mbox{\hyperlink{group__Ecore__Main__Loop__Group_ga95cf8e97dff0716433c2c5474d606a98}{ecore\_main\_loop\_quit}}();}
\DoxyCodeLine{   \textcolor{keywordflow}{return} \mbox{\hyperlink{group__Eina__Types__Group_ga05c12dacc8b4058994df842b41be85fc}{EINA\_TRUE}};}
\DoxyCodeLine{\}}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{keywordtype}{int}}
\DoxyCodeLine{main(\textcolor{keywordtype}{void})}
\DoxyCodeLine{\{}
\DoxyCodeLine{   \textcolor{keywordtype}{double} interval = 0.3; \textcolor{comment}{// tick each 0.3 seconds}}
\DoxyCodeLine{   Ecore\_Poller *poller1, *poller2, *poller3;}
\DoxyCodeLine{   \textcolor{keywordtype}{char} *str1 = \textcolor{stringliteral}{"poller1"};}
\DoxyCodeLine{   \textcolor{keywordtype}{char} *str2 = \textcolor{stringliteral}{"poller2"};}
\DoxyCodeLine{   \textcolor{keywordtype}{char} *str3 = \textcolor{stringliteral}{"poller3"};}
\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{   \_initial\_time = \mbox{\hyperlink{group__Ecore__Time__Group_ga98f2439b5d3e7114a75bfe2f0c22c4e9}{ecore\_time\_get}}();}
\DoxyCodeLine{}
\DoxyCodeLine{   \mbox{\hyperlink{group__Ecore__Poller__Group_ga466dff0c7fb7eb0f5b4e5a3825fa10ac}{ecore\_poller\_poll\_interval\_set}}(\mbox{\hyperlink{group__Ecore__Poller__Group_gga40d67f547376373ee34363b825874088a022dfec751388e380cf01621bd0f797f}{ECORE\_POLLER\_CORE}}, interval);}
\DoxyCodeLine{}
\DoxyCodeLine{   poller1 = \mbox{\hyperlink{group__Ecore__Poller__Group_gadd8ee7135864da4313bc88faa0a2d7c9}{ecore\_poller\_add}}(\mbox{\hyperlink{group__Ecore__Poller__Group_gga40d67f547376373ee34363b825874088a022dfec751388e380cf01621bd0f797f}{ECORE\_POLLER\_CORE}}, 4, \_poller\_print\_cb, str1);}
\DoxyCodeLine{   poller2 = \mbox{\hyperlink{group__Ecore__Poller__Group_gadd8ee7135864da4313bc88faa0a2d7c9}{ecore\_poller\_add}}(\mbox{\hyperlink{group__Ecore__Poller__Group_gga40d67f547376373ee34363b825874088a022dfec751388e380cf01621bd0f797f}{ECORE\_POLLER\_CORE}}, 8, \_poller\_print\_cb, str2);}
\DoxyCodeLine{   poller3 = \mbox{\hyperlink{group__Ecore__Poller__Group_gadd8ee7135864da4313bc88faa0a2d7c9}{ecore\_poller\_add}}(\mbox{\hyperlink{group__Ecore__Poller__Group_gga40d67f547376373ee34363b825874088a022dfec751388e380cf01621bd0f797f}{ECORE\_POLLER\_CORE}}, 30, \_poller\_quit\_cb, str3);}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{comment}{//   poller1 = efl\_add\_ref(ECORE\_POLLER\_CLASS, NULL, //         ecore\_poller\_constructor(efl\_added, ECORE\_POLLER\_CORE, 4, \_poller\_print\_cb, str1));}}
\DoxyCodeLine{\textcolor{comment}{//   poller2 = efl\_add\_ref(ECORE\_POLLER\_CLASS, NULL, //         ecore\_poller\_constructor(efl\_added, ECORE\_POLLER\_CORE, 8, \_poller\_print\_cb, str2));}}
\DoxyCodeLine{\textcolor{comment}{//   poller3 = efl\_add\_ref(ECORE\_POLLER\_CLASS, NULL, //         ecore\_poller\_constructor(efl\_added, ECORE\_POLLER\_CORE, 20, \_poller\_quit\_cb, str3));}}
\DoxyCodeLine{}
\DoxyCodeLine{}
\DoxyCodeLine{   \mbox{\hyperlink{group__Ecore__Main__Loop__Group_gaf103b9f668bb3e4fed12e52c6180132d}{ecore\_main\_loop\_begin}}();}
\DoxyCodeLine{}
\DoxyCodeLine{   printf(\textcolor{stringliteral}{"changing poller2 interval to 16\(\backslash\)n"});}
\DoxyCodeLine{}
\DoxyCodeLine{   \mbox{\hyperlink{group__Ecore__Poller__Group_gae9acf938d0e3b3ee84509d0c04ed628a}{ecore\_poller\_poller\_interval\_set}}(poller2, 16);}
\DoxyCodeLine{\textcolor{comment}{//   ecore\_poller\_interval\_set(poller2, 16, NULL);}}
\DoxyCodeLine{   \mbox{\hyperlink{group__Ecore__Main__Loop__Group_gaf103b9f668bb3e4fed12e52c6180132d}{ecore\_main\_loop\_begin}}();}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{comment}{//   efl\_unref(poller1);}}
\DoxyCodeLine{\textcolor{comment}{//   efl\_unref(poller2);}}
\DoxyCodeLine{\textcolor{comment}{//   efl\_unref(poller3);}}
\DoxyCodeLine{   \mbox{\hyperlink{group__Ecore__Poller__Group_ga52e6245cfbceaed9b721a1addd29d311}{ecore\_poller\_del}}(poller1);}
\DoxyCodeLine{   \mbox{\hyperlink{group__Ecore__Poller__Group_ga52e6245cfbceaed9b721a1addd29d311}{ecore\_poller\_del}}(poller2);}
\DoxyCodeLine{   \mbox{\hyperlink{group__Ecore__Poller__Group_ga52e6245cfbceaed9b721a1addd29d311}{ecore\_poller\_del}}(poller3);}
\DoxyCodeLine{}
\DoxyCodeLine{   \mbox{\hyperlink{group__Ecore__Init__Group_ga768298b932f18d7e7593a447493e5cde}{ecore\_shutdown}}();}
\DoxyCodeLine{\}}
\DoxyCodeLine{}
\end{DoxyCodeInclude}
 