\hypertarget{group__Ecore__Timer__Group}{\section{Ecore Timer functions}
\label{group__Ecore__Timer__Group}\index{Ecore Timer functions@{Ecore Timer functions}}
}


Ecore provides very flexible timer functionality.  


\subsection*{Typedefs}
\begin{DoxyCompactItemize}
\item 
\hypertarget{group__Ecore__Timer__Group_gaf96ffb609956658ec038e54bd39f46f0}{typedef \hyperlink{group__Eo_ga9f3010a50b61a892d41f4ec2bda73f4c}{Eo} \hyperlink{group__Ecore__Timer__Group_gaf96ffb609956658ec038e54bd39f46f0}{Ecore\+\_\+\+Timer}}\label{group__Ecore__Timer__Group_gaf96ffb609956658ec038e54bd39f46f0}

\begin{DoxyCompactList}\small\item\em A handle for timers. \end{DoxyCompactList}\end{DoxyCompactItemize}
\subsection*{Functions}
\begin{DoxyCompactItemize}
\item 
double \hyperlink{group__Ecore__Timer__Group_ga0045e6840c492e9aaf045fb79ac76c21}{ecore\+\_\+timer\+\_\+precision\+\_\+get} (void)
\begin{DoxyCompactList}\small\item\em Retrieves the current precision used by timer infrastructure. \end{DoxyCompactList}\item 
void \hyperlink{group__Ecore__Timer__Group_gaf7d0f56778f5614c63a69d4cfbee7b3d}{ecore\+\_\+timer\+\_\+precision\+\_\+set} (double precision)
\begin{DoxyCompactList}\small\item\em Sets the precision to be used by timer infrastructure. \end{DoxyCompactList}\item 
char $\ast$ \hyperlink{group__Ecore__Timer__Group_ga9ba51cdf9b709138dec62586721387dd}{ecore\+\_\+timer\+\_\+dump} (void)
\begin{DoxyCompactList}\small\item\em Creates a timer to call the given function in the given period of time. \end{DoxyCompactList}\end{DoxyCompactItemize}
\begin{DoxyCompactItemize}
\item 
\hypertarget{group__Ecore__Timer__Group_ga7b9cb9d24ecebfdbb957436e2e669402}{\hyperlink{group__Ecore__Timer__Group_gaf96ffb609956658ec038e54bd39f46f0}{Ecore\+\_\+\+Timer} $\ast$ {\bfseries ecore\+\_\+timer\+\_\+add} (double in, \hyperlink{group__Ecore__Main__Loop__Group_ga8a36ef1ac24bfa317a7826617264e530}{Ecore\+\_\+\+Task\+\_\+\+Cb} func, const void $\ast$data)}\label{group__Ecore__Timer__Group_ga7b9cb9d24ecebfdbb957436e2e669402}

\item 
\hyperlink{group__Ecore__Timer__Group_gaf96ffb609956658ec038e54bd39f46f0}{Ecore\+\_\+\+Timer} $\ast$ \hyperlink{group__Ecore__Timer__Group_ga51932ae74cf76de4f736322f65d8d475}{ecore\+\_\+timer\+\_\+loop\+\_\+add} (double in, \hyperlink{group__Ecore__Main__Loop__Group_ga8a36ef1ac24bfa317a7826617264e530}{Ecore\+\_\+\+Task\+\_\+\+Cb} func, const void $\ast$data)
\begin{DoxyCompactList}\small\item\em Creates a timer to call the given function in the given period of time. \end{DoxyCompactList}\item 
void $\ast$ \hyperlink{group__Ecore__Timer__Group_gaba2b599c7aabe3ab664dc3d47f62a33a}{ecore\+\_\+timer\+\_\+del} (\hyperlink{group__Ecore__Timer__Group_gaf96ffb609956658ec038e54bd39f46f0}{Ecore\+\_\+\+Timer} $\ast$timer)
\begin{DoxyCompactList}\small\item\em Delete the specified timer from the timer list. \end{DoxyCompactList}\item 
\hypertarget{group__Ecore__Timer__Group_ga9fb759297c1c828cafe5c3ccc1a2614b}{void {\bfseries ecore\+\_\+timer\+\_\+freeze} (\hyperlink{group__Ecore__Timer__Group_gaf96ffb609956658ec038e54bd39f46f0}{Ecore\+\_\+\+Timer} $\ast$timer)}\label{group__Ecore__Timer__Group_ga9fb759297c1c828cafe5c3ccc1a2614b}

\item 
\hypertarget{group__Ecore__Timer__Group_gaffb46c42b8d85ab8f2beac1a402c005b}{\hyperlink{group__Eina__Types__Group_ga3fe0caf72e93b1bab1ca8ee3ccf3f226}{Eina\+\_\+\+Bool} {\bfseries ecore\+\_\+timer\+\_\+freeze\+\_\+get} (\hyperlink{group__Ecore__Timer__Group_gaf96ffb609956658ec038e54bd39f46f0}{Ecore\+\_\+\+Timer} $\ast$timer)}\label{group__Ecore__Timer__Group_gaffb46c42b8d85ab8f2beac1a402c005b}

\item 
\hypertarget{group__Ecore__Timer__Group_gaa026b898456329411d043f36170ad644}{void {\bfseries ecore\+\_\+timer\+\_\+thaw} (\hyperlink{group__Ecore__Timer__Group_gaf96ffb609956658ec038e54bd39f46f0}{Ecore\+\_\+\+Timer} $\ast$timer)}\label{group__Ecore__Timer__Group_gaa026b898456329411d043f36170ad644}

\end{DoxyCompactItemize}


\subsection{Detailed Description}
Ecore provides very flexible timer functionality. 

The basic usage of timers, to call a certain function at a certain interval can be achieved with a single line\+: 
\begin{DoxyCode}
\hyperlink{group__Eina__Types__Group_ga3fe0caf72e93b1bab1ca8ee3ccf3f226}{Eina\_Bool} my\_func(\textcolor{keywordtype}{void} *data) \{
   do\_funky\_stuff\_with\_data(data);
   \textcolor{keywordflow}{return} \hyperlink{group__Ecore__Main__Loop__Group_ga1ee9db07f9a46a8b20fb83e1c6dbed09}{ECORE\_CALLBACK\_RENEW};
\}
ecore\_timer\_add(interval\_in\_seconds, my\_func, data\_given\_to\_function);
\end{DoxyCode}
 \begin{DoxyNote}{Note}
If the function was to be executed only once simply return {\ttfamily E\+C\+O\+R\+E\+\_\+\+C\+A\+L\+L\+B\+A\+C\+K\+\_\+\+C\+A\+N\+C\+E\+L} instead.
\end{DoxyNote}
An example that shows the usage of a lot of these\+: \begin{DoxyItemize}
\item \hyperlink{ecore_timer_example_c}{ecore timers -\/ Scheduled events} \end{DoxyItemize}


\subsection{Function Documentation}
\hypertarget{group__Ecore__Timer__Group_ga0045e6840c492e9aaf045fb79ac76c21}{\index{Ecore Timer functions@{Ecore Timer functions}!ecore\+\_\+timer\+\_\+precision\+\_\+get@{ecore\+\_\+timer\+\_\+precision\+\_\+get}}
\index{ecore\+\_\+timer\+\_\+precision\+\_\+get@{ecore\+\_\+timer\+\_\+precision\+\_\+get}!Ecore Timer functions@{Ecore Timer functions}}
\subsubsection[{ecore\+\_\+timer\+\_\+precision\+\_\+get}]{\setlength{\rightskip}{0pt plus 5cm}double ecore\+\_\+timer\+\_\+precision\+\_\+get (
\begin{DoxyParamCaption}
\item[{void}]{}
\end{DoxyParamCaption}
)}}\label{group__Ecore__Timer__Group_ga0045e6840c492e9aaf045fb79ac76c21}


Retrieves the current precision used by timer infrastructure. 

\begin{DoxyReturn}{Returns}
Current precision. 
\end{DoxyReturn}
\begin{DoxySeeAlso}{See also}
\hyperlink{group__Ecore__Timer__Group_gaf7d0f56778f5614c63a69d4cfbee7b3d}{ecore\+\_\+timer\+\_\+precision\+\_\+set()} 
\end{DoxySeeAlso}


References E\+I\+N\+A\+\_\+\+M\+A\+I\+N\+\_\+\+L\+O\+O\+P\+\_\+\+C\+H\+E\+C\+K\+\_\+\+R\+E\+T\+U\+R\+N\+\_\+\+V\+A\+L.

\hypertarget{group__Ecore__Timer__Group_gaf7d0f56778f5614c63a69d4cfbee7b3d}{\index{Ecore Timer functions@{Ecore Timer functions}!ecore\+\_\+timer\+\_\+precision\+\_\+set@{ecore\+\_\+timer\+\_\+precision\+\_\+set}}
\index{ecore\+\_\+timer\+\_\+precision\+\_\+set@{ecore\+\_\+timer\+\_\+precision\+\_\+set}!Ecore Timer functions@{Ecore Timer functions}}
\subsubsection[{ecore\+\_\+timer\+\_\+precision\+\_\+set}]{\setlength{\rightskip}{0pt plus 5cm}void ecore\+\_\+timer\+\_\+precision\+\_\+set (
\begin{DoxyParamCaption}
\item[{double}]{precision}
\end{DoxyParamCaption}
)}}\label{group__Ecore__Timer__Group_gaf7d0f56778f5614c63a69d4cfbee7b3d}


Sets the precision to be used by timer infrastructure. 


\begin{DoxyParams}{Parameters}
{\em precision} & allowed introduced timeout delay, in seconds.\\
\hline
\end{DoxyParams}
This sets the precision for {\bfseries all} timers. The precision determines how much of an difference from the requested interval is acceptable. One common reason to use this function is to {\bfseries increase} the allowed timeout and thus {\bfseries decrease} precision of the timers, this is because less precise the timers result in the system waking up less often and thus consuming less resources.

Be aware that kernel may delay delivery even further, these delays are always possible due other tasks having higher priorities or other scheduler policies.

Example\+: We have 2 timers, one that expires in a 2.\+0s and another that expires in 2.\+1s, if precision is 0.\+1s, then the Ecore will request for the next expire to happen in 2.\+1s and not 2.\+0s and another one of 0.\+1 as it would before.

\begin{DoxyNote}{Note}
Ecore is smart enough to see if there are timers in the precision range, if it does not, in our example if no second timer in (T + precision) existed, then it would use the minimum timeout. 
\end{DoxyNote}
\begin{Desc}
\item[Examples\+: ]\par
\hyperlink{ecore_timer_example_8c-example}{ecore\+\_\+timer\+\_\+example.\+c}.\end{Desc}


References E\+I\+N\+A\+\_\+\+M\+A\+I\+N\+\_\+\+L\+O\+O\+P\+\_\+\+C\+H\+E\+C\+K\+\_\+\+R\+E\+T\+U\+R\+N, and E\+R\+R.

\hypertarget{group__Ecore__Timer__Group_ga9ba51cdf9b709138dec62586721387dd}{\index{Ecore Timer functions@{Ecore Timer functions}!ecore\+\_\+timer\+\_\+dump@{ecore\+\_\+timer\+\_\+dump}}
\index{ecore\+\_\+timer\+\_\+dump@{ecore\+\_\+timer\+\_\+dump}!Ecore Timer functions@{Ecore Timer functions}}
\subsubsection[{ecore\+\_\+timer\+\_\+dump}]{\setlength{\rightskip}{0pt plus 5cm}char$\ast$ ecore\+\_\+timer\+\_\+dump (
\begin{DoxyParamCaption}
\item[{void}]{}
\end{DoxyParamCaption}
)}}\label{group__Ecore__Timer__Group_ga9ba51cdf9b709138dec62586721387dd}


Creates a timer to call the given function in the given period of time. 


\begin{DoxyParams}{Parameters}
{\em in} & The interval in seconds. \\
\hline
{\em func} & The given function. If {\ttfamily func} returns 1, the timer is rescheduled for the next interval {\ttfamily in}. \\
\hline
{\em data} & Data to pass to {\ttfamily func} when it is called. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
A timer object on success. {\ttfamily N\+U\+L\+L} on failure.
\end{DoxyReturn}
This function adds a timer and returns its handle on success and N\+U\+L\+L on failure. The function {\ttfamily func} will be called every {\ttfamily in} seconds. The function will be passed the {\ttfamily data} pointer as its parameter.

When the timer {\ttfamily func} is called, it must return a value of either 1 (or E\+C\+O\+R\+E\+\_\+\+C\+A\+L\+L\+B\+A\+C\+K\+\_\+\+R\+E\+N\+E\+W) or 0 (or E\+C\+O\+R\+E\+\_\+\+C\+A\+L\+L\+B\+A\+C\+K\+\_\+\+C\+A\+N\+C\+E\+L). If it returns 1, it will be called again at the next tick, or if it returns 0 it will be deleted automatically making any references/handles for it invalid. 

References E\+I\+N\+A\+\_\+\+I\+N\+L\+I\+S\+T\+\_\+\+F\+O\+R\+E\+A\+C\+H, E\+I\+N\+A\+\_\+\+L\+I\+S\+T\+\_\+\+F\+R\+E\+E, eina\+\_\+list\+\_\+sorted\+\_\+insert(), E\+I\+N\+A\+\_\+\+M\+A\+I\+N\+\_\+\+L\+O\+O\+P\+\_\+\+C\+H\+E\+C\+K\+\_\+\+R\+E\+T\+U\+R\+N\+\_\+\+V\+A\+L, eina\+\_\+strbuf\+\_\+append(), eina\+\_\+strbuf\+\_\+append\+\_\+printf(), eina\+\_\+strbuf\+\_\+free(), eina\+\_\+strbuf\+\_\+new(), and eina\+\_\+strbuf\+\_\+string\+\_\+steal().

\hypertarget{group__Ecore__Timer__Group_ga51932ae74cf76de4f736322f65d8d475}{\index{Ecore Timer functions@{Ecore Timer functions}!ecore\+\_\+timer\+\_\+loop\+\_\+add@{ecore\+\_\+timer\+\_\+loop\+\_\+add}}
\index{ecore\+\_\+timer\+\_\+loop\+\_\+add@{ecore\+\_\+timer\+\_\+loop\+\_\+add}!Ecore Timer functions@{Ecore Timer functions}}
\subsubsection[{ecore\+\_\+timer\+\_\+loop\+\_\+add}]{\setlength{\rightskip}{0pt plus 5cm}{\bf Ecore\+\_\+\+Timer}$\ast$ ecore\+\_\+timer\+\_\+loop\+\_\+add (
\begin{DoxyParamCaption}
\item[{double}]{in, }
\item[{{\bf Ecore\+\_\+\+Task\+\_\+\+Cb}}]{func, }
\item[{const void $\ast$}]{data}
\end{DoxyParamCaption}
)}}\label{group__Ecore__Timer__Group_ga51932ae74cf76de4f736322f65d8d475}


Creates a timer to call the given function in the given period of time. 


\begin{DoxyParams}{Parameters}
{\em in} & The interval in seconds from current loop time. \\
\hline
{\em func} & The given function. If {\ttfamily func} returns 1, the timer is rescheduled for the next interval {\ttfamily in}. \\
\hline
{\em data} & Data to pass to {\ttfamily func} when it is called. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
A timer object on success. {\ttfamily N\+U\+L\+L} on failure.
\end{DoxyReturn}
This is the same as ecore\+\_\+timer\+\_\+add(), but \char`\"{}now\char`\"{} is the time from \hyperlink{group__Ecore__Time__Group_gab53d952cc4c2f3ed032d535b307c43bd}{ecore\+\_\+loop\+\_\+time\+\_\+get()} not \hyperlink{group__Ecore__Time__Group_ga98f2439b5d3e7114a75bfe2f0c22c4e9}{ecore\+\_\+time\+\_\+get()} as ecore\+\_\+timer\+\_\+add() uses. See ecore\+\_\+timer\+\_\+add() for more details. \hypertarget{group__Ecore__Timer__Group_gaba2b599c7aabe3ab664dc3d47f62a33a}{\index{Ecore Timer functions@{Ecore Timer functions}!ecore\+\_\+timer\+\_\+del@{ecore\+\_\+timer\+\_\+del}}
\index{ecore\+\_\+timer\+\_\+del@{ecore\+\_\+timer\+\_\+del}!Ecore Timer functions@{Ecore Timer functions}}
\subsubsection[{ecore\+\_\+timer\+\_\+del}]{\setlength{\rightskip}{0pt plus 5cm}void$\ast$ ecore\+\_\+timer\+\_\+del (
\begin{DoxyParamCaption}
\item[{{\bf Ecore\+\_\+\+Timer} $\ast$}]{timer}
\end{DoxyParamCaption}
)}}\label{group__Ecore__Timer__Group_gaba2b599c7aabe3ab664dc3d47f62a33a}


Delete the specified timer from the timer list. 


\begin{DoxyParams}{Parameters}
{\em timer} & The timer to delete. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
The data pointer set for the timer when ecore\+\_\+timer\+\_\+add was called. {\ttfamily N\+U\+L\+L} is returned if the function is unsuccessful.
\end{DoxyReturn}
Note\+: {\ttfamily timer} must be a valid handle. If the timer function has already returned 0, the handle is no longer valid (and does not need to be delete). \begin{Desc}
\item[Examples\+: ]\par
\hyperlink{client_8c-example}{client.\+c}, \hyperlink{complex-types-server_8c-example}{complex-\/types-\/server.\+c}, \hyperlink{ecore_fd_handler_example_8c-example}{ecore\+\_\+fd\+\_\+handler\+\_\+example.\+c}, \hyperlink{ecore_idler_example_8c-example}{ecore\+\_\+idler\+\_\+example.\+c}, \hyperlink{ecore_timer_example_8c-example}{ecore\+\_\+timer\+\_\+example.\+c}, \hyperlink{evas-events_8c-example}{evas-\/events.\+c}, \hyperlink{test_growing_balls_8c-example}{test\+\_\+growing\+\_\+balls.\+c}, and \hyperlink{test_rotating_forever_8c-example}{test\+\_\+rotating\+\_\+forever.\+c}.\end{Desc}


References E\+I\+N\+A\+\_\+\+M\+A\+I\+N\+\_\+\+L\+O\+O\+P\+\_\+\+C\+H\+E\+C\+K\+\_\+\+R\+E\+T\+U\+R\+N\+\_\+\+V\+A\+L.



Referenced by ecore\+\_\+avahi\+\_\+del(), ecore\+\_\+con\+\_\+url\+\_\+shutdown(), ecore\+\_\+con\+\_\+url\+\_\+timeout\+\_\+set(), and ecore\+\_\+shutdown().

