\hypertarget{group__Ecore__Thread__Group}{}\doxysection{Ecore Thread functions}
\label{group__Ecore__Thread__Group}\index{Ecore Thread functions@{Ecore Thread functions}}


Facilities to run heavy tasks in different threads to avoid blocking the main loop.  


\doxysubsection*{Typedefs}
\begin{DoxyCompactItemize}
\item 
\mbox{\Hypertarget{group__Ecore__Thread__Group_ga0c2e1f8d562ccf80ecc0009ada72496f}\label{group__Ecore__Thread__Group_ga0c2e1f8d562ccf80ecc0009ada72496f}} 
typedef struct \+\_\+\+Ecore\+\_\+\+Thread {\bfseries Ecore\+\_\+\+Thread}
\begin{DoxyCompactList}\small\item\em A handle for threaded jobs. \end{DoxyCompactList}\item 
\mbox{\Hypertarget{group__Ecore__Thread__Group_ga2df413a7ddcf4912abe99c0be8de4d33}\label{group__Ecore__Thread__Group_ga2df413a7ddcf4912abe99c0be8de4d33}} 
typedef void($\ast$ {\bfseries Ecore\+\_\+\+Thread\+\_\+\+Cb}) (void $\ast$data, \mbox{\hyperlink{group__Ecore__Thread__Group_ga0c2e1f8d562ccf80ecc0009ada72496f}{Ecore\+\_\+\+Thread}} $\ast$thread)
\begin{DoxyCompactList}\small\item\em A callback used by Ecore\+\_\+\+Thread helper. \end{DoxyCompactList}\item 
\mbox{\Hypertarget{group__Ecore__Thread__Group_gad2d0337f9bd59848a3194bac11e71a1a}\label{group__Ecore__Thread__Group_gad2d0337f9bd59848a3194bac11e71a1a}} 
typedef void($\ast$ {\bfseries Ecore\+\_\+\+Thread\+\_\+\+Notify\+\_\+\+Cb}) (void $\ast$data, \mbox{\hyperlink{group__Ecore__Thread__Group_ga0c2e1f8d562ccf80ecc0009ada72496f}{Ecore\+\_\+\+Thread}} $\ast$thread, void $\ast$msg\+\_\+data)
\begin{DoxyCompactList}\small\item\em A callback used by the main loop to receive data sent by an \mbox{\hyperlink{group__Ecore__Thread__Group}{Ecore Thread functions}}. \end{DoxyCompactList}\end{DoxyCompactItemize}
\doxysubsection*{Functions}
\begin{DoxyCompactItemize}
\item 
\mbox{\hyperlink{group__Ecore__Thread__Group_ga0c2e1f8d562ccf80ecc0009ada72496f}{Ecore\+\_\+\+Thread}} $\ast$ \mbox{\hyperlink{group__Ecore__Thread__Group_ga6857d9e5bd717ae3d8417b39ec585c3f}{ecore\+\_\+thread\+\_\+run}} (\mbox{\hyperlink{group__Ecore__Thread__Group_ga2df413a7ddcf4912abe99c0be8de4d33}{Ecore\+\_\+\+Thread\+\_\+\+Cb}} func\+\_\+blocking, \mbox{\hyperlink{group__Ecore__Thread__Group_ga2df413a7ddcf4912abe99c0be8de4d33}{Ecore\+\_\+\+Thread\+\_\+\+Cb}} func\+\_\+end, \mbox{\hyperlink{group__Ecore__Thread__Group_ga2df413a7ddcf4912abe99c0be8de4d33}{Ecore\+\_\+\+Thread\+\_\+\+Cb}} func\+\_\+cancel, const void $\ast$data)
\begin{DoxyCompactList}\small\item\em Schedules a task to run in a parallel thread to avoid locking the main loop. \end{DoxyCompactList}\item 
\mbox{\hyperlink{group__Ecore__Thread__Group_ga0c2e1f8d562ccf80ecc0009ada72496f}{Ecore\+\_\+\+Thread}} $\ast$ \mbox{\hyperlink{group__Ecore__Thread__Group_ga941fa6f0313a6fe551f5d80e2a012bba}{ecore\+\_\+thread\+\_\+feedback\+\_\+run}} (\mbox{\hyperlink{group__Ecore__Thread__Group_ga2df413a7ddcf4912abe99c0be8de4d33}{Ecore\+\_\+\+Thread\+\_\+\+Cb}} func\+\_\+heavy, \mbox{\hyperlink{group__Ecore__Thread__Group_gad2d0337f9bd59848a3194bac11e71a1a}{Ecore\+\_\+\+Thread\+\_\+\+Notify\+\_\+\+Cb}} func\+\_\+notify, \mbox{\hyperlink{group__Ecore__Thread__Group_ga2df413a7ddcf4912abe99c0be8de4d33}{Ecore\+\_\+\+Thread\+\_\+\+Cb}} func\+\_\+end, \mbox{\hyperlink{group__Ecore__Thread__Group_ga2df413a7ddcf4912abe99c0be8de4d33}{Ecore\+\_\+\+Thread\+\_\+\+Cb}} func\+\_\+cancel, const void $\ast$data, \mbox{\hyperlink{group__Eina__Types__Group_ga3fe0caf72e93b1bab1ca8ee3ccf3f226}{Eina\+\_\+\+Bool}} try\+\_\+no\+\_\+queue)
\begin{DoxyCompactList}\small\item\em Launches a thread to run a task that can talk back to the main thread. \end{DoxyCompactList}\item 
\mbox{\hyperlink{group__Eina__Types__Group_ga3fe0caf72e93b1bab1ca8ee3ccf3f226}{Eina\+\_\+\+Bool}} \mbox{\hyperlink{group__Ecore__Thread__Group_gae9b9b20e1ed53c62c51617b55aed2511}{ecore\+\_\+thread\+\_\+cancel}} (\mbox{\hyperlink{group__Ecore__Thread__Group_ga0c2e1f8d562ccf80ecc0009ada72496f}{Ecore\+\_\+\+Thread}} $\ast$thread)
\begin{DoxyCompactList}\small\item\em Cancels a running thread. \end{DoxyCompactList}\item 
\mbox{\hyperlink{group__Eina__Types__Group_ga3fe0caf72e93b1bab1ca8ee3ccf3f226}{Eina\+\_\+\+Bool}} \mbox{\hyperlink{group__Ecore__Thread__Group_ga0b252a091ed78a33afed31cf147f58e2}{ecore\+\_\+thread\+\_\+wait}} (\mbox{\hyperlink{group__Ecore__Thread__Group_ga0c2e1f8d562ccf80ecc0009ada72496f}{Ecore\+\_\+\+Thread}} $\ast$thread, double wait)
\begin{DoxyCompactList}\small\item\em Blocks the main loop until the thread execution is over. \end{DoxyCompactList}\item 
\mbox{\hyperlink{group__Eina__Types__Group_ga3fe0caf72e93b1bab1ca8ee3ccf3f226}{Eina\+\_\+\+Bool}} \mbox{\hyperlink{group__Ecore__Thread__Group_ga792471a7ed00718b71d58b791ddbd08d}{ecore\+\_\+thread\+\_\+check}} (\mbox{\hyperlink{group__Ecore__Thread__Group_ga0c2e1f8d562ccf80ecc0009ada72496f}{Ecore\+\_\+\+Thread}} $\ast$thread)
\begin{DoxyCompactList}\small\item\em Checks if a thread is pending cancellation. \end{DoxyCompactList}\item 
\mbox{\hyperlink{group__Eina__Types__Group_ga3fe0caf72e93b1bab1ca8ee3ccf3f226}{Eina\+\_\+\+Bool}} \mbox{\hyperlink{group__Ecore__Thread__Group_ga8fadd19caae011ab1483665f09ce4d91}{ecore\+\_\+thread\+\_\+feedback}} (\mbox{\hyperlink{group__Ecore__Thread__Group_ga0c2e1f8d562ccf80ecc0009ada72496f}{Ecore\+\_\+\+Thread}} $\ast$thread, const void $\ast$msg\+\_\+data)
\begin{DoxyCompactList}\small\item\em Sends data from the worker thread to the main loop. \end{DoxyCompactList}\item 
\mbox{\hyperlink{group__Eina__Types__Group_ga3fe0caf72e93b1bab1ca8ee3ccf3f226}{Eina\+\_\+\+Bool}} \mbox{\hyperlink{group__Ecore__Thread__Group_gadf825c1a58f06bba2a304d025bed3185}{ecore\+\_\+thread\+\_\+reschedule}} (\mbox{\hyperlink{group__Ecore__Thread__Group_ga0c2e1f8d562ccf80ecc0009ada72496f}{Ecore\+\_\+\+Thread}} $\ast$thread)
\begin{DoxyCompactList}\small\item\em Asks for the function in the thread to be called again at a later time. \end{DoxyCompactList}\item 
int \mbox{\hyperlink{group__Ecore__Thread__Group_gad7a28588dc26d6af8b6db8abc3ef37ce}{ecore\+\_\+thread\+\_\+active\+\_\+get}} (void)
\begin{DoxyCompactList}\small\item\em Gets the number of active threads running jobs. \end{DoxyCompactList}\item 
int \mbox{\hyperlink{group__Ecore__Thread__Group_ga3e32f650cfe811e69bba7825c71b9070}{ecore\+\_\+thread\+\_\+pending\+\_\+get}} (void)
\begin{DoxyCompactList}\small\item\em Gets the number of short jobs waiting for a thread to run. \end{DoxyCompactList}\item 
int \mbox{\hyperlink{group__Ecore__Thread__Group_gaa5c56445198f7b03c1f080039499689a}{ecore\+\_\+thread\+\_\+pending\+\_\+feedback\+\_\+get}} (void)
\begin{DoxyCompactList}\small\item\em Gets the number of feedback jobs waiting for a thread to run. \end{DoxyCompactList}\item 
int \mbox{\hyperlink{group__Ecore__Thread__Group_gaeaa014287d578a200d41cca861bceac3}{ecore\+\_\+thread\+\_\+pending\+\_\+total\+\_\+get}} (void)
\begin{DoxyCompactList}\small\item\em Gets the total number of pending jobs. \end{DoxyCompactList}\item 
int \mbox{\hyperlink{group__Ecore__Thread__Group_gabad7972818b7fb1346ae7a098cd47220}{ecore\+\_\+thread\+\_\+max\+\_\+get}} (void)
\begin{DoxyCompactList}\small\item\em Gets the maximum number of threads that can run simultaneously. \end{DoxyCompactList}\item 
void \mbox{\hyperlink{group__Ecore__Thread__Group_gaaf965a46e0cc12857883806812af7693}{ecore\+\_\+thread\+\_\+max\+\_\+set}} (int num)
\begin{DoxyCompactList}\small\item\em Sets the maximum number of threads allowed to run simultaneously. \end{DoxyCompactList}\item 
void \mbox{\hyperlink{group__Ecore__Thread__Group_ga4324944541abf9f84861690b4ff66e18}{ecore\+\_\+thread\+\_\+max\+\_\+reset}} (void)
\begin{DoxyCompactList}\small\item\em Resets the maximum number of concurrently running threads to the default. \end{DoxyCompactList}\item 
int \mbox{\hyperlink{group__Ecore__Thread__Group_ga6e7703b3013d9c872449f6e2ec093b53}{ecore\+\_\+thread\+\_\+available\+\_\+get}} (void)
\begin{DoxyCompactList}\small\item\em Gets the number of threads available for running tasks. \end{DoxyCompactList}\item 
\mbox{\hyperlink{group__Eina__Types__Group_ga3fe0caf72e93b1bab1ca8ee3ccf3f226}{Eina\+\_\+\+Bool}} \mbox{\hyperlink{group__Ecore__Thread__Group_ga786b2db76a8bc29bca9f6f9cd41bc588}{ecore\+\_\+thread\+\_\+name\+\_\+set}} (\mbox{\hyperlink{group__Ecore__Thread__Group_ga0c2e1f8d562ccf80ecc0009ada72496f}{Ecore\+\_\+\+Thread}} $\ast$thread, const char $\ast$name)
\begin{DoxyCompactList}\small\item\em Sets the name of a given thread for debugging purposes. \end{DoxyCompactList}\item 
\mbox{\hyperlink{group__Eina__Types__Group_ga3fe0caf72e93b1bab1ca8ee3ccf3f226}{Eina\+\_\+\+Bool}} \mbox{\hyperlink{group__Ecore__Thread__Group_ga6878f550a9bcc8002c0c709b4b4dca66}{ecore\+\_\+thread\+\_\+local\+\_\+data\+\_\+add}} (\mbox{\hyperlink{group__Ecore__Thread__Group_ga0c2e1f8d562ccf80ecc0009ada72496f}{Ecore\+\_\+\+Thread}} $\ast$thread, const char $\ast$key, void $\ast$value, \mbox{\hyperlink{group__Eina__Types__Group_gadbac560ba2bca5c61d97bfbb542018f3}{Eina\+\_\+\+Free\+\_\+\+Cb}} cb, \mbox{\hyperlink{group__Eina__Types__Group_ga3fe0caf72e93b1bab1ca8ee3ccf3f226}{Eina\+\_\+\+Bool}} direct)
\begin{DoxyCompactList}\small\item\em Adds some data to a hash local to the thread. \end{DoxyCompactList}\item 
void $\ast$ \mbox{\hyperlink{group__Ecore__Thread__Group_gac28873eb1d87140dfe1bba4d370ae112}{ecore\+\_\+thread\+\_\+local\+\_\+data\+\_\+set}} (\mbox{\hyperlink{group__Ecore__Thread__Group_ga0c2e1f8d562ccf80ecc0009ada72496f}{Ecore\+\_\+\+Thread}} $\ast$thread, const char $\ast$key, void $\ast$value, \mbox{\hyperlink{group__Eina__Types__Group_gadbac560ba2bca5c61d97bfbb542018f3}{Eina\+\_\+\+Free\+\_\+\+Cb}} cb)
\begin{DoxyCompactList}\small\item\em Sets some data in the hash local to the given thread. \end{DoxyCompactList}\item 
void $\ast$ \mbox{\hyperlink{group__Ecore__Thread__Group_gaa99c30f01228217ddd0e510e4e99610b}{ecore\+\_\+thread\+\_\+local\+\_\+data\+\_\+find}} (\mbox{\hyperlink{group__Ecore__Thread__Group_ga0c2e1f8d562ccf80ecc0009ada72496f}{Ecore\+\_\+\+Thread}} $\ast$thread, const char $\ast$key)
\begin{DoxyCompactList}\small\item\em Gets data stored in the hash local to the given thread. \end{DoxyCompactList}\item 
\mbox{\hyperlink{group__Eina__Types__Group_ga3fe0caf72e93b1bab1ca8ee3ccf3f226}{Eina\+\_\+\+Bool}} \mbox{\hyperlink{group__Ecore__Thread__Group_gad3c1d51a24772b885b26486be86c2779}{ecore\+\_\+thread\+\_\+local\+\_\+data\+\_\+del}} (\mbox{\hyperlink{group__Ecore__Thread__Group_ga0c2e1f8d562ccf80ecc0009ada72496f}{Ecore\+\_\+\+Thread}} $\ast$thread, const char $\ast$key)
\begin{DoxyCompactList}\small\item\em Deletes from the thread\textquotesingle{}s hash the data corresponding to the given key. \end{DoxyCompactList}\item 
\mbox{\hyperlink{group__Eina__Types__Group_ga3fe0caf72e93b1bab1ca8ee3ccf3f226}{Eina\+\_\+\+Bool}} \mbox{\hyperlink{group__Ecore__Thread__Group_ga4e9de7492f8400e19ddd157d8cc21811}{ecore\+\_\+thread\+\_\+global\+\_\+data\+\_\+add}} (const char $\ast$key, void $\ast$value, \mbox{\hyperlink{group__Eina__Types__Group_gadbac560ba2bca5c61d97bfbb542018f3}{Eina\+\_\+\+Free\+\_\+\+Cb}} cb, \mbox{\hyperlink{group__Eina__Types__Group_ga3fe0caf72e93b1bab1ca8ee3ccf3f226}{Eina\+\_\+\+Bool}} direct)
\begin{DoxyCompactList}\small\item\em Adds some data to a hash shared by all threads. \end{DoxyCompactList}\item 
void $\ast$ \mbox{\hyperlink{group__Ecore__Thread__Group_gab05209a2ef2f0a16bb69bbdb53a8bcb0}{ecore\+\_\+thread\+\_\+global\+\_\+data\+\_\+set}} (const char $\ast$key, void $\ast$value, \mbox{\hyperlink{group__Eina__Types__Group_gadbac560ba2bca5c61d97bfbb542018f3}{Eina\+\_\+\+Free\+\_\+\+Cb}} cb)
\begin{DoxyCompactList}\small\item\em Sets some data in the hash shared by all threads. \end{DoxyCompactList}\item 
void $\ast$ \mbox{\hyperlink{group__Ecore__Thread__Group_ga0eea48ec2cec77087c3f246347f26909}{ecore\+\_\+thread\+\_\+global\+\_\+data\+\_\+find}} (const char $\ast$key)
\begin{DoxyCompactList}\small\item\em Gets data stored in the hash shared by all threads. \end{DoxyCompactList}\item 
\mbox{\hyperlink{group__Eina__Types__Group_ga3fe0caf72e93b1bab1ca8ee3ccf3f226}{Eina\+\_\+\+Bool}} \mbox{\hyperlink{group__Ecore__Thread__Group_ga8e53feb974331550744cbc2e40dc9132}{ecore\+\_\+thread\+\_\+global\+\_\+data\+\_\+del}} (const char $\ast$key)
\begin{DoxyCompactList}\small\item\em Deletes from the shared hash the data corresponding to the given key. \end{DoxyCompactList}\item 
void $\ast$ \mbox{\hyperlink{group__Ecore__Thread__Group_ga78f34d8bd0806f68a56105662c54e202}{ecore\+\_\+thread\+\_\+global\+\_\+data\+\_\+wait}} (const char $\ast$key, double seconds)
\begin{DoxyCompactList}\small\item\em Gets data stored in the shared hash, or wait for it if it doesn\textquotesingle{}t exist. \end{DoxyCompactList}\end{DoxyCompactItemize}


\doxysubsection{Detailed Description}
Facilities to run heavy tasks in different threads to avoid blocking the main loop. 

The EFL is, for the most part, not thread safe. This means that if you have some task running in another thread and you have, for example, an Evas object to show the status progress of this task, you cannot update the object from within the thread. This can only be done from the main thread, the one running the main loop. This problem can be solved by running a thread that sends messages to the main one using an \mbox{\hyperlink{group__Ecore__Pipe__Group}{Ecore\+\_\+\+Pipe}}, but when you need to handle other things like cancelling the thread, your code grows in complexity and gets much harder to maintain.

Ecore Thread is here to solve that problem. It is {\bfseries{not}} a simple wrapper around standard POSIX threads (or the equivalent in other systems) and it\textquotesingle{}s not meant to be used to run parallel tasks throughout the entire duration of the program, especially when these tasks are performance critical, as Ecore manages these tasks using a pool of threads based on system configuration.

What Ecore Thread does, is make it a lot easier to dispatch a worker function to perform some heavy task and then get the result once it completes, without blocking the application\textquotesingle{}s UI. In addition, cancelling and rescheduling comes practically for free and the developer needs not worry about how many threads are launched, since Ecore will schedule them according to the number of processors the system has and maximum amount of concurrent threads set for the application.

At the system level, Ecore will start a new thread on an as-\/needed basis until the maximum set is reached. When no more threads can be launched, new worker functions will be queued in a waiting list until a thread becomes available. This way, system threads will be shared throughout different worker functions, but running only one at a time. At the same time, a worker function that is rescheduled may be run on a different thread the next time.

The \mbox{\hyperlink{group__Ecore__Thread__Group_ga0c2e1f8d562ccf80ecc0009ada72496f}{Ecore\+\_\+\+Thread}} handler has two meanings, depending on what context it is on. The one returned when starting a worker with any of the functions \mbox{\hyperlink{group__Ecore__Thread__Group_ga6857d9e5bd717ae3d8417b39ec585c3f}{ecore\+\_\+thread\+\_\+run()}} or \mbox{\hyperlink{group__Ecore__Thread__Group_ga941fa6f0313a6fe551f5d80e2a012bba}{ecore\+\_\+thread\+\_\+feedback\+\_\+run()}} is an identifier of that specific instance of the function and can be used from the main loop with the \mbox{\hyperlink{group__Ecore__Thread__Group_gae9b9b20e1ed53c62c51617b55aed2511}{ecore\+\_\+thread\+\_\+cancel()}} and \mbox{\hyperlink{group__Ecore__Thread__Group_ga792471a7ed00718b71d58b791ddbd08d}{ecore\+\_\+thread\+\_\+check()}} functions. This handler must not be shared with the worker function function running in the thread. This same handler will be the one received on the {\ttfamily end}, {\ttfamily cancel} and {\ttfamily feedback} callbacks.

The worker function, that\textquotesingle{}s the one running in the thread, also receives an \mbox{\hyperlink{group__Ecore__Thread__Group_ga0c2e1f8d562ccf80ecc0009ada72496f}{Ecore\+\_\+\+Thread}} handler that can be used with \mbox{\hyperlink{group__Ecore__Thread__Group_gae9b9b20e1ed53c62c51617b55aed2511}{ecore\+\_\+thread\+\_\+cancel()}} and \mbox{\hyperlink{group__Ecore__Thread__Group_ga792471a7ed00718b71d58b791ddbd08d}{ecore\+\_\+thread\+\_\+check()}}, sharing the flag with the main loop. But this handler is also associated with the thread where the function is running. This has strong implications when working with thread local data.

There are two kinds of worker threads Ecore handles\+: simple, or short, workers and feedback workers.

The first kind is for simple functions that perform a usually small but time consuming task. Ecore will run this function in a thread as soon as one becomes available and notify the calling user of its completion once the task is done.

The following image shows the flow of a program running four tasks on a pool of two threads.

  
\begin{DoxyImageNoCaption}
  \mbox{\includegraphics[width=\\textwidth]{ecore_thread}}
\end{DoxyImageNoCaption}


For larger tasks that may require continuous communication with the main program, the feedback workers provide the same functionality plus a way for the function running in the thread to send messages to the main thread.

The next diagram omits some details shown in the previous one regarding how threads are spawned and tasks are queued, but illustrates how feedback jobs communicate with the main loop and the special case of threads running out of pool.

  
\begin{DoxyImageNoCaption}
  \mbox{\includegraphics[width=\\textwidth]{ecore_thread_feedback}}
\end{DoxyImageNoCaption}


See an overview example in \mbox{\hyperlink{ecore_thread_example_c}{Ecore\+\_\+\+Thread -\/ API overview}}. 

\doxysubsection{Function Documentation}
\mbox{\Hypertarget{group__Ecore__Thread__Group_ga6857d9e5bd717ae3d8417b39ec585c3f}\label{group__Ecore__Thread__Group_ga6857d9e5bd717ae3d8417b39ec585c3f}} 
\index{Ecore Thread functions@{Ecore Thread functions}!ecore\_thread\_run@{ecore\_thread\_run}}
\index{ecore\_thread\_run@{ecore\_thread\_run}!Ecore Thread functions@{Ecore Thread functions}}
\doxysubsubsection{\texorpdfstring{ecore\_thread\_run()}{ecore\_thread\_run()}}
{\footnotesize\ttfamily \mbox{\hyperlink{group__Ecore__Thread__Group_ga0c2e1f8d562ccf80ecc0009ada72496f}{Ecore\+\_\+\+Thread}} $\ast$ ecore\+\_\+thread\+\_\+run (\begin{DoxyParamCaption}\item[{\mbox{\hyperlink{group__Ecore__Thread__Group_ga2df413a7ddcf4912abe99c0be8de4d33}{Ecore\+\_\+\+Thread\+\_\+\+Cb}}}]{func\+\_\+blocking,  }\item[{\mbox{\hyperlink{group__Ecore__Thread__Group_ga2df413a7ddcf4912abe99c0be8de4d33}{Ecore\+\_\+\+Thread\+\_\+\+Cb}}}]{func\+\_\+end,  }\item[{\mbox{\hyperlink{group__Ecore__Thread__Group_ga2df413a7ddcf4912abe99c0be8de4d33}{Ecore\+\_\+\+Thread\+\_\+\+Cb}}}]{func\+\_\+cancel,  }\item[{const void $\ast$}]{data }\end{DoxyParamCaption})}



Schedules a task to run in a parallel thread to avoid locking the main loop. 


\begin{DoxyParams}{Parameters}
{\em func\+\_\+blocking} & The function that should run in another thread. \\
\hline
{\em func\+\_\+end} & Function to call from main loop when {\ttfamily func\+\_\+blocking} completes its task successfully (may be NULL) \\
\hline
{\em func\+\_\+cancel} & Function to call from main loop if the thread running {\ttfamily func\+\_\+blocking} is cancelled or fails to start (may be NULL) \\
\hline
{\em data} & User context data to pass to all callbacks. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
A new thread handler, or {\ttfamily NULL} on failure.
\end{DoxyReturn}
This function will try to create a new thread to run {\ttfamily func\+\_\+blocking} in, or if the maximum number of concurrent threads has been reached, will add it to the pending list, where it will wait until a thread becomes available. The return value will be an \mbox{\hyperlink{group__Ecore__Thread__Group_ga0c2e1f8d562ccf80ecc0009ada72496f}{Ecore\+\_\+\+Thread}} handle that can be used to cancel the thread before its completion.

\begin{DoxyNote}{Note}
This function should always return immediately, but in the rare case that Ecore is built with no thread support, {\ttfamily func\+\_\+blocking} will be called here, actually blocking the main loop.
\end{DoxyNote}
Once a thread becomes available, {\ttfamily func\+\_\+blocking} will be run in it until it finishes, then {\ttfamily func\+\_\+end} is called from the thread containing the main loop to inform the user of its completion. While in {\ttfamily func\+\_\+blocking}, no functions from the EFL can be used, except for those from Eina that are marked to be thread-\/safe. Even for the latter, caution needs to be taken if the data is shared across several threads.

{\ttfamily func\+\_\+end} will be called from the main thread when {\ttfamily func\+\_\+blocking} ends, so here it\textquotesingle{}s safe to use anything from the EFL freely.

The thread can also be cancelled before its completion calling \mbox{\hyperlink{group__Ecore__Thread__Group_gae9b9b20e1ed53c62c51617b55aed2511}{ecore\+\_\+thread\+\_\+cancel()}}, either from the main thread or {\ttfamily func\+\_\+blocking}. In this case, {\ttfamily func\+\_\+cancel} will be called, also from the main thread to inform of this happening. If the thread could not be created, this function will be called and it\textquotesingle{}s {\ttfamily thread} parameter will be NULL. It\textquotesingle{}s also safe to call any EFL function here, as it will be running in the main thread.

Inside {\ttfamily func\+\_\+blocking}, it\textquotesingle{}s possible to call \mbox{\hyperlink{group__Ecore__Thread__Group_gadf825c1a58f06bba2a304d025bed3185}{ecore\+\_\+thread\+\_\+reschedule()}} to tell Ecore that this function should be called again.

Be aware that no assumptions can be made about the order in which the {\ttfamily func\+\_\+end} callbacks for each task will be called. Once the function is running in a different thread, it\textquotesingle{}s the OS that will handle its running schedule, and different functions may take longer to finish than others. Also remember that just starting several tasks together doesn\textquotesingle{}t mean they will be running at the same time. Ecore will schedule them based on the number of threads available for the particular system it\textquotesingle{}s running in, so some of the jobs started may be waiting until another one finishes before it can execute its own {\ttfamily func\+\_\+blocking}.

\begin{DoxySeeAlso}{See also}
\mbox{\hyperlink{group__Ecore__Thread__Group_ga941fa6f0313a6fe551f5d80e2a012bba}{ecore\+\_\+thread\+\_\+feedback\+\_\+run()}} 

\mbox{\hyperlink{group__Ecore__Thread__Group_gae9b9b20e1ed53c62c51617b55aed2511}{ecore\+\_\+thread\+\_\+cancel()}} 

\mbox{\hyperlink{group__Ecore__Thread__Group_gadf825c1a58f06bba2a304d025bed3185}{ecore\+\_\+thread\+\_\+reschedule()}} 

\mbox{\hyperlink{group__Ecore__Thread__Group_gaaf965a46e0cc12857883806812af7693}{ecore\+\_\+thread\+\_\+max\+\_\+set()}} 
\end{DoxySeeAlso}
\begin{Desc}
\item[Examples]\par
\mbox{\hyperlink{ecore_thread_example_8c-example}{ecore\+\_\+thread\+\_\+example.\+c}}, and \mbox{\hyperlink{efl_thread_6_8c-example}{efl\+\_\+thread\+\_\+6.\+c}}.\end{Desc}


References \mbox{\hyperlink{group__Eina__Types__Group_ga1feb115f8e9913e806e090d9bd5a7301}{EINA\+\_\+\+FALSE}}, \mbox{\hyperlink{group__Eina__List__Group_ga625698a383dda8fc0db245a1c7608c49}{eina\+\_\+list\+\_\+append()}}, \mbox{\hyperlink{group__Eina__List__Group_ga6e81c26272c54177d087b29c965af4d8}{eina\+\_\+list\+\_\+remove()}}, \mbox{\hyperlink{group__Eina__Lock__Group_ga2974eb3f18404edcc375910cc7e4859c}{EINA\+\_\+\+MAIN\+\_\+\+LOOP\+\_\+\+CHECK\+\_\+\+RETURN\+\_\+\+VAL}}, \mbox{\hyperlink{group__Eina__Main__Group_ga169380f8b2c21bc95b2af6ba5d013395}{eina\+\_\+threads\+\_\+init()}}, \mbox{\hyperlink{group__Eina__Main__Group_gae68d340aaeb79e01f0f2ba0292fef5a3}{eina\+\_\+threads\+\_\+shutdown()}}, and \mbox{\hyperlink{group__Eina__Types__Group_ga05c12dacc8b4058994df842b41be85fc}{EINA\+\_\+\+TRUE}}.



Referenced by \mbox{\hyperlink{group__Ethumb__Client__Basics_gab69c8658057776f0d103237164737753}{ethumb\+\_\+client\+\_\+thumb\+\_\+exists()}}.

\mbox{\Hypertarget{group__Ecore__Thread__Group_ga941fa6f0313a6fe551f5d80e2a012bba}\label{group__Ecore__Thread__Group_ga941fa6f0313a6fe551f5d80e2a012bba}} 
\index{Ecore Thread functions@{Ecore Thread functions}!ecore\_thread\_feedback\_run@{ecore\_thread\_feedback\_run}}
\index{ecore\_thread\_feedback\_run@{ecore\_thread\_feedback\_run}!Ecore Thread functions@{Ecore Thread functions}}
\doxysubsubsection{\texorpdfstring{ecore\_thread\_feedback\_run()}{ecore\_thread\_feedback\_run()}}
{\footnotesize\ttfamily \mbox{\hyperlink{group__Ecore__Thread__Group_ga0c2e1f8d562ccf80ecc0009ada72496f}{Ecore\+\_\+\+Thread}} $\ast$ ecore\+\_\+thread\+\_\+feedback\+\_\+run (\begin{DoxyParamCaption}\item[{\mbox{\hyperlink{group__Ecore__Thread__Group_ga2df413a7ddcf4912abe99c0be8de4d33}{Ecore\+\_\+\+Thread\+\_\+\+Cb}}}]{func\+\_\+heavy,  }\item[{\mbox{\hyperlink{group__Ecore__Thread__Group_gad2d0337f9bd59848a3194bac11e71a1a}{Ecore\+\_\+\+Thread\+\_\+\+Notify\+\_\+\+Cb}}}]{func\+\_\+notify,  }\item[{\mbox{\hyperlink{group__Ecore__Thread__Group_ga2df413a7ddcf4912abe99c0be8de4d33}{Ecore\+\_\+\+Thread\+\_\+\+Cb}}}]{func\+\_\+end,  }\item[{\mbox{\hyperlink{group__Ecore__Thread__Group_ga2df413a7ddcf4912abe99c0be8de4d33}{Ecore\+\_\+\+Thread\+\_\+\+Cb}}}]{func\+\_\+cancel,  }\item[{const void $\ast$}]{data,  }\item[{\mbox{\hyperlink{group__Eina__Types__Group_ga3fe0caf72e93b1bab1ca8ee3ccf3f226}{Eina\+\_\+\+Bool}}}]{try\+\_\+no\+\_\+queue }\end{DoxyParamCaption})}



Launches a thread to run a task that can talk back to the main thread. 


\begin{DoxyParams}{Parameters}
{\em func\+\_\+heavy} & The function that should run in another thread. \\
\hline
{\em func\+\_\+notify} & Function that receives the data sent from the thread \\
\hline
{\em func\+\_\+end} & Function to call from main loop when {\ttfamily func\+\_\+heavy} completes its task successfully \\
\hline
{\em func\+\_\+cancel} & Function to call from main loop if the thread running {\ttfamily func\+\_\+heavy} is cancelled or fails to start \\
\hline
{\em data} & User context data to pass to all callback. \\
\hline
{\em try\+\_\+no\+\_\+queue} & If you want to run outside of the thread pool. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
A new thread handler, or {\ttfamily NULL} on failure.
\end{DoxyReturn}
See \mbox{\hyperlink{group__Ecore__Thread__Group_ga6857d9e5bd717ae3d8417b39ec585c3f}{ecore\+\_\+thread\+\_\+run()}} for a general description of this function.

The difference with the above is that \mbox{\hyperlink{group__Ecore__Thread__Group_ga6857d9e5bd717ae3d8417b39ec585c3f}{ecore\+\_\+thread\+\_\+run()}} is meant for tasks that don\textquotesingle{}t need to communicate anything until they finish, while this function is provided with a new callback, {\ttfamily func\+\_\+notify}, that will be called from the main thread for every message sent from {\ttfamily func\+\_\+heavy} with \mbox{\hyperlink{group__Ecore__Thread__Group_ga8fadd19caae011ab1483665f09ce4d91}{ecore\+\_\+thread\+\_\+feedback()}}.

Like \mbox{\hyperlink{group__Ecore__Thread__Group_ga6857d9e5bd717ae3d8417b39ec585c3f}{ecore\+\_\+thread\+\_\+run()}}, a new thread will be launched to run {\ttfamily func\+\_\+heavy} unless the maximum number of simultaneous threads has been reached, in which case the function will be scheduled to run whenever a running task ends and a thread becomes free. But if {\ttfamily try\+\_\+no\+\_\+queue} is set, Ecore will first try to launch a thread outside of the pool to run the task. If it fails, it will revert to the normal behaviour of using a thread from the pool as if {\ttfamily try\+\_\+no\+\_\+queue} had not been set.

Keep in mind that Ecore handles the thread pool based on the number of CPUs available, but running a thread outside of the pool doesn\textquotesingle{}t count for this, so having too many of them may have drastic effects over the program\textquotesingle{}s performance.

\begin{DoxySeeAlso}{See also}
\mbox{\hyperlink{group__Ecore__Thread__Group_ga8fadd19caae011ab1483665f09ce4d91}{ecore\+\_\+thread\+\_\+feedback()}} 

\mbox{\hyperlink{group__Ecore__Thread__Group_ga6857d9e5bd717ae3d8417b39ec585c3f}{ecore\+\_\+thread\+\_\+run()}} 

\mbox{\hyperlink{group__Ecore__Thread__Group_gae9b9b20e1ed53c62c51617b55aed2511}{ecore\+\_\+thread\+\_\+cancel()}} 

\mbox{\hyperlink{group__Ecore__Thread__Group_gadf825c1a58f06bba2a304d025bed3185}{ecore\+\_\+thread\+\_\+reschedule()}} 

\mbox{\hyperlink{group__Ecore__Thread__Group_gaaf965a46e0cc12857883806812af7693}{ecore\+\_\+thread\+\_\+max\+\_\+set()}} 
\end{DoxySeeAlso}
\begin{Desc}
\item[Examples]\par
\mbox{\hyperlink{ecore_thread_example_8c-example}{ecore\+\_\+thread\+\_\+example.\+c}}, and \mbox{\hyperlink{efl_thread_5_8c-example}{efl\+\_\+thread\+\_\+5.\+c}}.\end{Desc}


References \mbox{\hyperlink{group__Eina__Types__Group_ga1feb115f8e9913e806e090d9bd5a7301}{EINA\+\_\+\+FALSE}}, \mbox{\hyperlink{group__Eina__List__Group_ga625698a383dda8fc0db245a1c7608c49}{eina\+\_\+list\+\_\+append()}}, \mbox{\hyperlink{group__Eina__List__Group_ga6e81c26272c54177d087b29c965af4d8}{eina\+\_\+list\+\_\+remove()}}, \mbox{\hyperlink{group__Eina__Lock__Group_ga2974eb3f18404edcc375910cc7e4859c}{EINA\+\_\+\+MAIN\+\_\+\+LOOP\+\_\+\+CHECK\+\_\+\+RETURN\+\_\+\+VAL}}, \mbox{\hyperlink{group__Eina__Main__Group_ga169380f8b2c21bc95b2af6ba5d013395}{eina\+\_\+threads\+\_\+init()}}, \mbox{\hyperlink{group__Eina__Main__Group_gae68d340aaeb79e01f0f2ba0292fef5a3}{eina\+\_\+threads\+\_\+shutdown()}}, and \mbox{\hyperlink{group__Eina__Types__Group_ga05c12dacc8b4058994df842b41be85fc}{EINA\+\_\+\+TRUE}}.



Referenced by \mbox{\hyperlink{group__Store_ga2b5c5d9d1c770e7d8b40adafd8c58bdb}{elm\+\_\+store\+\_\+filesystem\+\_\+directory\+\_\+set()}}, and \mbox{\hyperlink{group__Elput__Input__Group_ga073d531060f708080f8dbc3ba02d2af9}{elput\+\_\+input\+\_\+init()}}.

\mbox{\Hypertarget{group__Ecore__Thread__Group_gae9b9b20e1ed53c62c51617b55aed2511}\label{group__Ecore__Thread__Group_gae9b9b20e1ed53c62c51617b55aed2511}} 
\index{Ecore Thread functions@{Ecore Thread functions}!ecore\_thread\_cancel@{ecore\_thread\_cancel}}
\index{ecore\_thread\_cancel@{ecore\_thread\_cancel}!Ecore Thread functions@{Ecore Thread functions}}
\doxysubsubsection{\texorpdfstring{ecore\_thread\_cancel()}{ecore\_thread\_cancel()}}
{\footnotesize\ttfamily \mbox{\hyperlink{group__Eina__Types__Group_ga3fe0caf72e93b1bab1ca8ee3ccf3f226}{Eina\+\_\+\+Bool}} ecore\+\_\+thread\+\_\+cancel (\begin{DoxyParamCaption}\item[{\mbox{\hyperlink{group__Ecore__Thread__Group_ga0c2e1f8d562ccf80ecc0009ada72496f}{Ecore\+\_\+\+Thread}} $\ast$}]{thread }\end{DoxyParamCaption})}



Cancels a running thread. 


\begin{DoxyParams}{Parameters}
{\em thread} & The thread to cancel. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
Will return {\ttfamily EINA\+\_\+\+TRUE} if the thread has been cancelled, {\ttfamily EINA\+\_\+\+FALSE} if it is pending.
\end{DoxyReturn}
This function can be called both in the main loop or in the running thread.

This function cancels a running thread. If {\ttfamily thread} can be immediately cancelled (it\textquotesingle{}s still pending execution after creation or rescheduling), then the {\ttfamily cancel} callback will be called, {\ttfamily thread} will be freed and the function will return {\ttfamily EINA\+\_\+\+TRUE}.

If the thread is already running, then this function returns {\ttfamily EINA\+\_\+\+FALSE} after marking the {\ttfamily thread} as pending cancellation. For the thread to actually be terminated, it needs to return from the user function back into Ecore control. This can happen in several ways\+: \begin{DoxyItemize}
\item The function ends and returns normally. If it hadn\textquotesingle{}t been cancelled, {\ttfamily func\+\_\+end} would be called here, but instead {\ttfamily func\+\_\+cancel} will happen. \item The function returns after requesting to be rescheduled with \mbox{\hyperlink{group__Ecore__Thread__Group_gadf825c1a58f06bba2a304d025bed3185}{ecore\+\_\+thread\+\_\+reschedule()}}. \item The function is prepared to leave early by checking if \mbox{\hyperlink{group__Ecore__Thread__Group_ga792471a7ed00718b71d58b791ddbd08d}{ecore\+\_\+thread\+\_\+check()}} returns {\ttfamily EINA\+\_\+\+TRUE}.\end{DoxyItemize}
\begin{DoxyItemize}
\item The function marks the thread as cancellable using \mbox{\hyperlink{group__Eina__Thread__Group_ga58f736ee21de29c3c51e9fd37d829b6f}{eina\+\_\+thread\+\_\+cancellable\+\_\+set()}}, allowing the thread to be terminated at explicit cancellation points defined with \mbox{\hyperlink{group__Eina__Thread__Group_ga85b73a0592645d298a96d62f60732379}{eina\+\_\+thread\+\_\+cancel\+\_\+checkpoint()}} or with syscalls mentioned at man\+:pthreads(7). This allows blocking operations such as network or disk access to be stopped without polling \mbox{\hyperlink{group__Ecore__Thread__Group_ga792471a7ed00718b71d58b791ddbd08d}{ecore\+\_\+thread\+\_\+check()}}. Note that a cancelled thread may leak resources if no cleanup function is registered with \mbox{\hyperlink{group__Eina__Thread__Group_gacbfb74a9554f86829a021b6074ef9b31}{EINA\+\_\+\+THREAD\+\_\+\+CLEANUP\+\_\+\+PUSH()}}. Consider running such code using \mbox{\hyperlink{group__Eina__Thread__Group_ga3a6ec5c1b2cad7c3a6f0dd38c2dcb71b}{eina\+\_\+thread\+\_\+cancellable\+\_\+run()}}.\end{DoxyItemize}
The user function can cancel itself by calling \mbox{\hyperlink{group__Ecore__Thread__Group_gae9b9b20e1ed53c62c51617b55aed2511}{ecore\+\_\+thread\+\_\+cancel()}}, but it should always use the \mbox{\hyperlink{group__Ecore__Thread__Group_ga0c2e1f8d562ccf80ecc0009ada72496f}{Ecore\+\_\+\+Thread}} handle passed to it and never share it with the main loop thread by means of shared user data or any other way.

{\ttfamily thread} will be freed and should not be used again if this function returns {\ttfamily EINA\+\_\+\+TRUE} or after the {\ttfamily func\+\_\+cancel} callback returns.

\begin{DoxySeeAlso}{See also}
\mbox{\hyperlink{group__Ecore__Thread__Group_ga792471a7ed00718b71d58b791ddbd08d}{ecore\+\_\+thread\+\_\+check()}} 

\mbox{\hyperlink{group__Eina__Thread__Group_ga3a6ec5c1b2cad7c3a6f0dd38c2dcb71b}{eina\+\_\+thread\+\_\+cancellable\+\_\+run()}} 
\end{DoxySeeAlso}
\begin{Desc}
\item[Examples]\par
\mbox{\hyperlink{ecore_thread_example_8c-example}{ecore\+\_\+thread\+\_\+example.\+c}}, \mbox{\hyperlink{efl_thread_5_8c-example}{efl\+\_\+thread\+\_\+5.\+c}}, and \mbox{\hyperlink{efl_thread_6_8c-example}{efl\+\_\+thread\+\_\+6.\+c}}.\end{Desc}


References \mbox{\hyperlink{group__Eina__Types__Group_ga1feb115f8e9913e806e090d9bd5a7301}{EINA\+\_\+\+FALSE}}, \mbox{\hyperlink{group__Eina__List__Group_gac6efafc19f526d916cdb9757240a8773}{EINA\+\_\+\+LIST\+\_\+\+FOREACH}}, \mbox{\hyperlink{group__Eina__List__Group_gaf86ee0fd9fe0643ece301fc86f04e720}{eina\+\_\+list\+\_\+remove\+\_\+list()}}, \mbox{\hyperlink{group__Eina__Thread__Group_ga80dc486bb33402ffc20741d3086a8277}{eina\+\_\+thread\+\_\+cancel()}}, and \mbox{\hyperlink{group__Eina__Types__Group_ga05c12dacc8b4058994df842b41be85fc}{EINA\+\_\+\+TRUE}}.



Referenced by \mbox{\hyperlink{group__Eio__Helper_ga91439a6bb5b13ee3162f7fa8644d1b17}{eio\+\_\+file\+\_\+cancel()}}, \mbox{\hyperlink{group__Eio__Helper_ga7c3ad77c3f9a0346aab50f474af54b6c}{eio\+\_\+shutdown()}}, \mbox{\hyperlink{group__Store_ga2b5c5d9d1c770e7d8b40adafd8c58bdb}{elm\+\_\+store\+\_\+filesystem\+\_\+directory\+\_\+set()}}, \mbox{\hyperlink{group__Store_ga04e5d401569956202edd4657a4503c58}{elm\+\_\+store\+\_\+free()}}, \mbox{\hyperlink{group__Elput__Input__Group_gaad0cd8a925620087e80b3e74fcaad30c}{elput\+\_\+input\+\_\+shutdown()}}, \mbox{\hyperlink{group__Elput__Manager__Group_gac4abcc0fed4ef131bd70892aff4ae3f5}{elput\+\_\+manager\+\_\+disconnect()}}, and \mbox{\hyperlink{group__Ethumb__Client__Basics_gad96b376ead632e96723ca9f9b0735918}{ethumb\+\_\+client\+\_\+thumb\+\_\+exists\+\_\+cancel()}}.

\mbox{\Hypertarget{group__Ecore__Thread__Group_ga0b252a091ed78a33afed31cf147f58e2}\label{group__Ecore__Thread__Group_ga0b252a091ed78a33afed31cf147f58e2}} 
\index{Ecore Thread functions@{Ecore Thread functions}!ecore\_thread\_wait@{ecore\_thread\_wait}}
\index{ecore\_thread\_wait@{ecore\_thread\_wait}!Ecore Thread functions@{Ecore Thread functions}}
\doxysubsubsection{\texorpdfstring{ecore\_thread\_wait()}{ecore\_thread\_wait()}}
{\footnotesize\ttfamily \mbox{\hyperlink{group__Eina__Types__Group_ga3fe0caf72e93b1bab1ca8ee3ccf3f226}{Eina\+\_\+\+Bool}} ecore\+\_\+thread\+\_\+wait (\begin{DoxyParamCaption}\item[{\mbox{\hyperlink{group__Ecore__Thread__Group_ga0c2e1f8d562ccf80ecc0009ada72496f}{Ecore\+\_\+\+Thread}} $\ast$}]{thread,  }\item[{double}]{wait }\end{DoxyParamCaption})}



Blocks the main loop until the thread execution is over. 

\begin{DoxySince}{Since}
1.\+13.\+0
\end{DoxySince}

\begin{DoxyParams}{Parameters}
{\em thread} & The thread to wait on. \\
\hline
{\em wait} & Maximum time to wait before exiting anyway. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
EINA\+\_\+\+TRUE if the thread execution is over.
\end{DoxyReturn}
Note\+: This function should only be called in the main loop. 

References \mbox{\hyperlink{group__Ecore__Main__Loop__Group_gace69e5961a239cbf4f586fae651e4cc9}{ecore\+\_\+main\+\_\+loop\+\_\+thread\+\_\+safe\+\_\+call\+\_\+wait()}}, \mbox{\hyperlink{group__Ecore__Time__Group_ga98f2439b5d3e7114a75bfe2f0c22c4e9}{ecore\+\_\+time\+\_\+get()}}, \mbox{\hyperlink{group__Eina__Types__Group_ga1feb115f8e9913e806e090d9bd5a7301}{EINA\+\_\+\+FALSE}}, and \mbox{\hyperlink{group__Eina__Types__Group_ga05c12dacc8b4058994df842b41be85fc}{EINA\+\_\+\+TRUE}}.



Referenced by \mbox{\hyperlink{group__Eio__Helper_ga7c3ad77c3f9a0346aab50f474af54b6c}{eio\+\_\+shutdown()}}.

\mbox{\Hypertarget{group__Ecore__Thread__Group_ga792471a7ed00718b71d58b791ddbd08d}\label{group__Ecore__Thread__Group_ga792471a7ed00718b71d58b791ddbd08d}} 
\index{Ecore Thread functions@{Ecore Thread functions}!ecore\_thread\_check@{ecore\_thread\_check}}
\index{ecore\_thread\_check@{ecore\_thread\_check}!Ecore Thread functions@{Ecore Thread functions}}
\doxysubsubsection{\texorpdfstring{ecore\_thread\_check()}{ecore\_thread\_check()}}
{\footnotesize\ttfamily \mbox{\hyperlink{group__Eina__Types__Group_ga3fe0caf72e93b1bab1ca8ee3ccf3f226}{Eina\+\_\+\+Bool}} ecore\+\_\+thread\+\_\+check (\begin{DoxyParamCaption}\item[{\mbox{\hyperlink{group__Ecore__Thread__Group_ga0c2e1f8d562ccf80ecc0009ada72496f}{Ecore\+\_\+\+Thread}} $\ast$}]{thread }\end{DoxyParamCaption})}



Checks if a thread is pending cancellation. 


\begin{DoxyParams}{Parameters}
{\em thread} & The thread to test. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
{\ttfamily EINA\+\_\+\+TRUE} if the thread is pending cancellation, {\ttfamily EINA\+\_\+\+FALSE} if it is not.
\end{DoxyReturn}
This function can be called both in the main loop or in the running thread.

When \mbox{\hyperlink{group__Ecore__Thread__Group_gae9b9b20e1ed53c62c51617b55aed2511}{ecore\+\_\+thread\+\_\+cancel()}} is called on an already running task, the thread is marked as pending cancellation. This function returns {\ttfamily EINA\+\_\+\+TRUE} if this mark is set for the given {\ttfamily thread} and can be used from the main loop thread to check if a still active thread has been cancelled, or from the user function running in the thread to check if it should stop doing what it\textquotesingle{}s doing and return early, effectively cancelling the task.

\begin{DoxySeeAlso}{See also}
\mbox{\hyperlink{group__Ecore__Thread__Group_gae9b9b20e1ed53c62c51617b55aed2511}{ecore\+\_\+thread\+\_\+cancel()}} 
\end{DoxySeeAlso}
\begin{Desc}
\item[Examples]\par
\mbox{\hyperlink{ecore_thread_example_8c-example}{ecore\+\_\+thread\+\_\+example.\+c}}, \mbox{\hyperlink{efl_thread_5_8c-example}{efl\+\_\+thread\+\_\+5.\+c}}, and \mbox{\hyperlink{efl_thread_6_8c-example}{efl\+\_\+thread\+\_\+6.\+c}}.\end{Desc}


References \mbox{\hyperlink{group__Eina__Types__Group_ga05c12dacc8b4058994df842b41be85fc}{EINA\+\_\+\+TRUE}}.



Referenced by \mbox{\hyperlink{group__Eio__Helper_ga4d6d16c11f262df789dbbb1f94130fd4}{eio\+\_\+file\+\_\+check()}}, and \mbox{\hyperlink{group__Ethumb__Client__Basics_gae68364004bf3ba3247fab20efc58f146}{ethumb\+\_\+client\+\_\+thumb\+\_\+exists\+\_\+check()}}.

\mbox{\Hypertarget{group__Ecore__Thread__Group_ga8fadd19caae011ab1483665f09ce4d91}\label{group__Ecore__Thread__Group_ga8fadd19caae011ab1483665f09ce4d91}} 
\index{Ecore Thread functions@{Ecore Thread functions}!ecore\_thread\_feedback@{ecore\_thread\_feedback}}
\index{ecore\_thread\_feedback@{ecore\_thread\_feedback}!Ecore Thread functions@{Ecore Thread functions}}
\doxysubsubsection{\texorpdfstring{ecore\_thread\_feedback()}{ecore\_thread\_feedback()}}
{\footnotesize\ttfamily \mbox{\hyperlink{group__Eina__Types__Group_ga3fe0caf72e93b1bab1ca8ee3ccf3f226}{Eina\+\_\+\+Bool}} ecore\+\_\+thread\+\_\+feedback (\begin{DoxyParamCaption}\item[{\mbox{\hyperlink{group__Ecore__Thread__Group_ga0c2e1f8d562ccf80ecc0009ada72496f}{Ecore\+\_\+\+Thread}} $\ast$}]{thread,  }\item[{const void $\ast$}]{msg\+\_\+data }\end{DoxyParamCaption})}



Sends data from the worker thread to the main loop. 


\begin{DoxyParams}{Parameters}
{\em thread} & The current \mbox{\hyperlink{group__Ecore__Thread__Group_ga0c2e1f8d562ccf80ecc0009ada72496f}{Ecore\+\_\+\+Thread}} context to send data from \\
\hline
{\em msg\+\_\+data} & Data to be transmitted to the main loop \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
{\ttfamily EINA\+\_\+\+TRUE} if {\ttfamily msg\+\_\+data} was successfully sent to main loop, {\ttfamily EINA\+\_\+\+FALSE} if anything goes wrong.
\end{DoxyReturn}
You should use this function only in the {\ttfamily func\+\_\+heavy} call.

Only the address to {\ttfamily msg\+\_\+data} will be sent and once this function returns {\ttfamily EINA\+\_\+\+TRUE}, the job running in the thread should never touch the contents of it again. The data sent should be malloc()\textquotesingle{}ed or something similar, as long as it\textquotesingle{}s not memory local to the thread that risks being overwritten or deleted once it goes out of scope or the thread finishes.

Care must be taken that {\ttfamily msg\+\_\+data} is properly freed in the {\ttfamily func\+\_\+notify} callback set when creating the thread.

\begin{DoxySeeAlso}{See also}
\mbox{\hyperlink{group__Ecore__Thread__Group_ga941fa6f0313a6fe551f5d80e2a012bba}{ecore\+\_\+thread\+\_\+feedback\+\_\+run()}} 
\end{DoxySeeAlso}
\begin{Desc}
\item[Examples]\par
\mbox{\hyperlink{ecore_thread_example_8c-example}{ecore\+\_\+thread\+\_\+example.\+c}}, and \mbox{\hyperlink{efl_thread_5_8c-example}{efl\+\_\+thread\+\_\+5.\+c}}.\end{Desc}


References \mbox{\hyperlink{group__Ecore__Main__Loop__Group_ga12c98ccc13eb136ed62f8177d12a8fc0}{ecore\+\_\+main\+\_\+loop\+\_\+thread\+\_\+safe\+\_\+call\+\_\+async()}}, \mbox{\hyperlink{group__Eina__Types__Group_ga1feb115f8e9913e806e090d9bd5a7301}{EINA\+\_\+\+FALSE}}, and \mbox{\hyperlink{group__Eina__Types__Group_ga05c12dacc8b4058994df842b41be85fc}{EINA\+\_\+\+TRUE}}.

\mbox{\Hypertarget{group__Ecore__Thread__Group_gadf825c1a58f06bba2a304d025bed3185}\label{group__Ecore__Thread__Group_gadf825c1a58f06bba2a304d025bed3185}} 
\index{Ecore Thread functions@{Ecore Thread functions}!ecore\_thread\_reschedule@{ecore\_thread\_reschedule}}
\index{ecore\_thread\_reschedule@{ecore\_thread\_reschedule}!Ecore Thread functions@{Ecore Thread functions}}
\doxysubsubsection{\texorpdfstring{ecore\_thread\_reschedule()}{ecore\_thread\_reschedule()}}
{\footnotesize\ttfamily \mbox{\hyperlink{group__Eina__Types__Group_ga3fe0caf72e93b1bab1ca8ee3ccf3f226}{Eina\+\_\+\+Bool}} ecore\+\_\+thread\+\_\+reschedule (\begin{DoxyParamCaption}\item[{\mbox{\hyperlink{group__Ecore__Thread__Group_ga0c2e1f8d562ccf80ecc0009ada72496f}{Ecore\+\_\+\+Thread}} $\ast$}]{thread }\end{DoxyParamCaption})}



Asks for the function in the thread to be called again at a later time. 


\begin{DoxyParams}{Parameters}
{\em thread} & The current \mbox{\hyperlink{group__Ecore__Thread__Group_ga0c2e1f8d562ccf80ecc0009ada72496f}{Ecore\+\_\+\+Thread}} context to rescheduled \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
{\ttfamily EINA\+\_\+\+TRUE} if the task was successfully rescheduled, {\ttfamily EINA\+\_\+\+FALSE} if anything goes wrong.
\end{DoxyReturn}
This function should be called only from the same function represented by {\ttfamily thread}.

Calling this function will mark the thread for a reschedule, so as soon as it returns, it will be added to the end of the list of pending tasks. If no other tasks are waiting or there are sufficient threads available, the rescheduled task will be launched again immediately.

This should never return {\ttfamily EINA\+\_\+\+FALSE}, unless it was called from the wrong thread or with the wrong arguments.

The {\ttfamily func\+\_\+end} callback set when the thread is created will not be called until the function in the thread returns without being rescheduled. Similarly, if the {\ttfamily thread} is cancelled, the reschedule will not take effect. \begin{Desc}
\item[Examples]\par
\mbox{\hyperlink{ecore_thread_example_8c-example}{ecore\+\_\+thread\+\_\+example.\+c}}.\end{Desc}


References \mbox{\hyperlink{group__Eina__Types__Group_ga1feb115f8e9913e806e090d9bd5a7301}{EINA\+\_\+\+FALSE}}, and \mbox{\hyperlink{group__Eina__Types__Group_ga05c12dacc8b4058994df842b41be85fc}{EINA\+\_\+\+TRUE}}.

\mbox{\Hypertarget{group__Ecore__Thread__Group_gad7a28588dc26d6af8b6db8abc3ef37ce}\label{group__Ecore__Thread__Group_gad7a28588dc26d6af8b6db8abc3ef37ce}} 
\index{Ecore Thread functions@{Ecore Thread functions}!ecore\_thread\_active\_get@{ecore\_thread\_active\_get}}
\index{ecore\_thread\_active\_get@{ecore\_thread\_active\_get}!Ecore Thread functions@{Ecore Thread functions}}
\doxysubsubsection{\texorpdfstring{ecore\_thread\_active\_get()}{ecore\_thread\_active\_get()}}
{\footnotesize\ttfamily int ecore\+\_\+thread\+\_\+active\+\_\+get (\begin{DoxyParamCaption}\item[{void}]{ }\end{DoxyParamCaption})}



Gets the number of active threads running jobs. 

\begin{DoxyReturn}{Returns}
Number of active threads running jobs
\end{DoxyReturn}
This returns the number of threads currently running jobs of any type through the Ecore\+\_\+\+Thread API.

\begin{DoxyNote}{Note}
Jobs started through the \mbox{\hyperlink{group__Ecore__Thread__Group_ga941fa6f0313a6fe551f5d80e2a012bba}{ecore\+\_\+thread\+\_\+feedback\+\_\+run()}} function with the {\ttfamily try\+\_\+no\+\_\+queue} parameter set to {\ttfamily EINA\+\_\+\+TRUE} will not be accounted for in the return of this function unless the thread creation fails and it falls back to using one from the pool. 
\end{DoxyNote}
\begin{Desc}
\item[Examples]\par
\mbox{\hyperlink{ecore_thread_example_8c-example}{ecore\+\_\+thread\+\_\+example.\+c}}.\end{Desc}


References \mbox{\hyperlink{group__Eina__Lock__Group_ga2974eb3f18404edcc375910cc7e4859c}{EINA\+\_\+\+MAIN\+\_\+\+LOOP\+\_\+\+CHECK\+\_\+\+RETURN\+\_\+\+VAL}}.

\mbox{\Hypertarget{group__Ecore__Thread__Group_ga3e32f650cfe811e69bba7825c71b9070}\label{group__Ecore__Thread__Group_ga3e32f650cfe811e69bba7825c71b9070}} 
\index{Ecore Thread functions@{Ecore Thread functions}!ecore\_thread\_pending\_get@{ecore\_thread\_pending\_get}}
\index{ecore\_thread\_pending\_get@{ecore\_thread\_pending\_get}!Ecore Thread functions@{Ecore Thread functions}}
\doxysubsubsection{\texorpdfstring{ecore\_thread\_pending\_get()}{ecore\_thread\_pending\_get()}}
{\footnotesize\ttfamily int ecore\+\_\+thread\+\_\+pending\+\_\+get (\begin{DoxyParamCaption}\item[{void}]{ }\end{DoxyParamCaption})}



Gets the number of short jobs waiting for a thread to run. 

\begin{DoxyReturn}{Returns}
Number of pending threads running \char`\"{}short\char`\"{} jobs
\end{DoxyReturn}
This returns the number of tasks started with \mbox{\hyperlink{group__Ecore__Thread__Group_ga6857d9e5bd717ae3d8417b39ec585c3f}{ecore\+\_\+thread\+\_\+run()}} that are pending, waiting for a thread to become available to run them. \begin{Desc}
\item[Examples]\par
\mbox{\hyperlink{ecore_thread_example_8c-example}{ecore\+\_\+thread\+\_\+example.\+c}}.\end{Desc}


References \mbox{\hyperlink{group__Eina__Lock__Group_ga2974eb3f18404edcc375910cc7e4859c}{EINA\+\_\+\+MAIN\+\_\+\+LOOP\+\_\+\+CHECK\+\_\+\+RETURN\+\_\+\+VAL}}.

\mbox{\Hypertarget{group__Ecore__Thread__Group_gaa5c56445198f7b03c1f080039499689a}\label{group__Ecore__Thread__Group_gaa5c56445198f7b03c1f080039499689a}} 
\index{Ecore Thread functions@{Ecore Thread functions}!ecore\_thread\_pending\_feedback\_get@{ecore\_thread\_pending\_feedback\_get}}
\index{ecore\_thread\_pending\_feedback\_get@{ecore\_thread\_pending\_feedback\_get}!Ecore Thread functions@{Ecore Thread functions}}
\doxysubsubsection{\texorpdfstring{ecore\_thread\_pending\_feedback\_get()}{ecore\_thread\_pending\_feedback\_get()}}
{\footnotesize\ttfamily int ecore\+\_\+thread\+\_\+pending\+\_\+feedback\+\_\+get (\begin{DoxyParamCaption}\item[{void}]{ }\end{DoxyParamCaption})}



Gets the number of feedback jobs waiting for a thread to run. 

\begin{DoxyReturn}{Returns}
Number of pending threads running \char`\"{}feedback\char`\"{} jobs
\end{DoxyReturn}
This returns the number of tasks started with \mbox{\hyperlink{group__Ecore__Thread__Group_ga941fa6f0313a6fe551f5d80e2a012bba}{ecore\+\_\+thread\+\_\+feedback\+\_\+run()}} that are pending, waiting for a thread to become available to run them. \begin{Desc}
\item[Examples]\par
\mbox{\hyperlink{ecore_thread_example_8c-example}{ecore\+\_\+thread\+\_\+example.\+c}}.\end{Desc}


References \mbox{\hyperlink{group__Eina__Lock__Group_ga2974eb3f18404edcc375910cc7e4859c}{EINA\+\_\+\+MAIN\+\_\+\+LOOP\+\_\+\+CHECK\+\_\+\+RETURN\+\_\+\+VAL}}.

\mbox{\Hypertarget{group__Ecore__Thread__Group_gaeaa014287d578a200d41cca861bceac3}\label{group__Ecore__Thread__Group_gaeaa014287d578a200d41cca861bceac3}} 
\index{Ecore Thread functions@{Ecore Thread functions}!ecore\_thread\_pending\_total\_get@{ecore\_thread\_pending\_total\_get}}
\index{ecore\_thread\_pending\_total\_get@{ecore\_thread\_pending\_total\_get}!Ecore Thread functions@{Ecore Thread functions}}
\doxysubsubsection{\texorpdfstring{ecore\_thread\_pending\_total\_get()}{ecore\_thread\_pending\_total\_get()}}
{\footnotesize\ttfamily int ecore\+\_\+thread\+\_\+pending\+\_\+total\+\_\+get (\begin{DoxyParamCaption}\item[{void}]{ }\end{DoxyParamCaption})}



Gets the total number of pending jobs. 

\begin{DoxyReturn}{Returns}
Number of pending threads running jobs
\end{DoxyReturn}
Same as the sum of \mbox{\hyperlink{group__Ecore__Thread__Group_ga3e32f650cfe811e69bba7825c71b9070}{ecore\+\_\+thread\+\_\+pending\+\_\+get()}} and \mbox{\hyperlink{group__Ecore__Thread__Group_gaa5c56445198f7b03c1f080039499689a}{ecore\+\_\+thread\+\_\+pending\+\_\+feedback\+\_\+get()}}. \begin{Desc}
\item[Examples]\par
\mbox{\hyperlink{ecore_thread_example_8c-example}{ecore\+\_\+thread\+\_\+example.\+c}}.\end{Desc}


References \mbox{\hyperlink{group__Eina__Lock__Group_ga2974eb3f18404edcc375910cc7e4859c}{EINA\+\_\+\+MAIN\+\_\+\+LOOP\+\_\+\+CHECK\+\_\+\+RETURN\+\_\+\+VAL}}.

\mbox{\Hypertarget{group__Ecore__Thread__Group_gabad7972818b7fb1346ae7a098cd47220}\label{group__Ecore__Thread__Group_gabad7972818b7fb1346ae7a098cd47220}} 
\index{Ecore Thread functions@{Ecore Thread functions}!ecore\_thread\_max\_get@{ecore\_thread\_max\_get}}
\index{ecore\_thread\_max\_get@{ecore\_thread\_max\_get}!Ecore Thread functions@{Ecore Thread functions}}
\doxysubsubsection{\texorpdfstring{ecore\_thread\_max\_get()}{ecore\_thread\_max\_get()}}
{\footnotesize\ttfamily int ecore\+\_\+thread\+\_\+max\+\_\+get (\begin{DoxyParamCaption}\item[{void}]{ }\end{DoxyParamCaption})}



Gets the maximum number of threads that can run simultaneously. 

\begin{DoxyReturn}{Returns}
Max possible number of Ecore\+\_\+\+Thread\textquotesingle{}s running concurrently
\end{DoxyReturn}
This returns the maximum number of Ecore\+\_\+\+Thread\textquotesingle{}s that may be running at the same time. If this number is reached, new jobs started by either \mbox{\hyperlink{group__Ecore__Thread__Group_ga6857d9e5bd717ae3d8417b39ec585c3f}{ecore\+\_\+thread\+\_\+run()}} or \mbox{\hyperlink{group__Ecore__Thread__Group_ga941fa6f0313a6fe551f5d80e2a012bba}{ecore\+\_\+thread\+\_\+feedback\+\_\+run()}} will be added to the respective pending queue until one of the running threads finishes its task and becomes available to run a new one.

By default, this will be the proportional to the number of CPU cores found, and will be at least 1 so at least 1 worker can run through the quque of work to do.

\begin{DoxySeeAlso}{See also}
\mbox{\hyperlink{group__Ecore__Thread__Group_gaaf965a46e0cc12857883806812af7693}{ecore\+\_\+thread\+\_\+max\+\_\+set()}} 

\mbox{\hyperlink{group__Ecore__Thread__Group_ga4324944541abf9f84861690b4ff66e18}{ecore\+\_\+thread\+\_\+max\+\_\+reset()}} 
\end{DoxySeeAlso}
\begin{Desc}
\item[Examples]\par
\mbox{\hyperlink{ecore_thread_example_8c-example}{ecore\+\_\+thread\+\_\+example.\+c}}.\end{Desc}


References \mbox{\hyperlink{group__Eina__Lock__Group_ga2974eb3f18404edcc375910cc7e4859c}{EINA\+\_\+\+MAIN\+\_\+\+LOOP\+\_\+\+CHECK\+\_\+\+RETURN\+\_\+\+VAL}}.

\mbox{\Hypertarget{group__Ecore__Thread__Group_gaaf965a46e0cc12857883806812af7693}\label{group__Ecore__Thread__Group_gaaf965a46e0cc12857883806812af7693}} 
\index{Ecore Thread functions@{Ecore Thread functions}!ecore\_thread\_max\_set@{ecore\_thread\_max\_set}}
\index{ecore\_thread\_max\_set@{ecore\_thread\_max\_set}!Ecore Thread functions@{Ecore Thread functions}}
\doxysubsubsection{\texorpdfstring{ecore\_thread\_max\_set()}{ecore\_thread\_max\_set()}}
{\footnotesize\ttfamily void ecore\+\_\+thread\+\_\+max\+\_\+set (\begin{DoxyParamCaption}\item[{int}]{num }\end{DoxyParamCaption})}



Sets the maximum number of threads allowed to run simultaneously. 


\begin{DoxyParams}{Parameters}
{\em num} & The new maximum\\
\hline
\end{DoxyParams}
This sets a new value for the maximum number of concurrently running Ecore\+\_\+\+Thread\textquotesingle{}s. It {\bfseries{must}} an interger of at least 1 and may be limited to a reasonable value as to not overload the system too much with too many workers. This limit may change based on the number of CPU cores detected.

\begin{DoxySeeAlso}{See also}
\mbox{\hyperlink{group__Ecore__Thread__Group_gabad7972818b7fb1346ae7a098cd47220}{ecore\+\_\+thread\+\_\+max\+\_\+get()}} 

\mbox{\hyperlink{group__Ecore__Thread__Group_ga4324944541abf9f84861690b4ff66e18}{ecore\+\_\+thread\+\_\+max\+\_\+reset()}} 
\end{DoxySeeAlso}
\begin{Desc}
\item[Examples]\par
\mbox{\hyperlink{ecore_thread_example_8c-example}{ecore\+\_\+thread\+\_\+example.\+c}}.\end{Desc}


References \mbox{\hyperlink{group__Eina__Cpu__Group_ga5c8042e9fb859130d59fed84ca0c747c}{eina\+\_\+cpu\+\_\+count()}}, and \mbox{\hyperlink{group__Eina__Lock__Group_ga6900a2b986f5536b73210e2560675cb0}{EINA\+\_\+\+MAIN\+\_\+\+LOOP\+\_\+\+CHECK\+\_\+\+RETURN}}.

\mbox{\Hypertarget{group__Ecore__Thread__Group_ga4324944541abf9f84861690b4ff66e18}\label{group__Ecore__Thread__Group_ga4324944541abf9f84861690b4ff66e18}} 
\index{Ecore Thread functions@{Ecore Thread functions}!ecore\_thread\_max\_reset@{ecore\_thread\_max\_reset}}
\index{ecore\_thread\_max\_reset@{ecore\_thread\_max\_reset}!Ecore Thread functions@{Ecore Thread functions}}
\doxysubsubsection{\texorpdfstring{ecore\_thread\_max\_reset()}{ecore\_thread\_max\_reset()}}
{\footnotesize\ttfamily void ecore\+\_\+thread\+\_\+max\+\_\+reset (\begin{DoxyParamCaption}\item[{void}]{ }\end{DoxyParamCaption})}



Resets the maximum number of concurrently running threads to the default. 

This resets the value returned by \mbox{\hyperlink{group__Ecore__Thread__Group_gabad7972818b7fb1346ae7a098cd47220}{ecore\+\_\+thread\+\_\+max\+\_\+get()}} back to its default.

\begin{DoxySeeAlso}{See also}
\mbox{\hyperlink{group__Ecore__Thread__Group_gabad7972818b7fb1346ae7a098cd47220}{ecore\+\_\+thread\+\_\+max\+\_\+get()}} 

\mbox{\hyperlink{group__Ecore__Thread__Group_gaaf965a46e0cc12857883806812af7693}{ecore\+\_\+thread\+\_\+max\+\_\+set()}} 
\end{DoxySeeAlso}


References \mbox{\hyperlink{group__Eina__Cpu__Group_ga5c8042e9fb859130d59fed84ca0c747c}{eina\+\_\+cpu\+\_\+count()}}, and \mbox{\hyperlink{group__Eina__Lock__Group_ga6900a2b986f5536b73210e2560675cb0}{EINA\+\_\+\+MAIN\+\_\+\+LOOP\+\_\+\+CHECK\+\_\+\+RETURN}}.

\mbox{\Hypertarget{group__Ecore__Thread__Group_ga6e7703b3013d9c872449f6e2ec093b53}\label{group__Ecore__Thread__Group_ga6e7703b3013d9c872449f6e2ec093b53}} 
\index{Ecore Thread functions@{Ecore Thread functions}!ecore\_thread\_available\_get@{ecore\_thread\_available\_get}}
\index{ecore\_thread\_available\_get@{ecore\_thread\_available\_get}!Ecore Thread functions@{Ecore Thread functions}}
\doxysubsubsection{\texorpdfstring{ecore\_thread\_available\_get()}{ecore\_thread\_available\_get()}}
{\footnotesize\ttfamily int ecore\+\_\+thread\+\_\+available\+\_\+get (\begin{DoxyParamCaption}\item[{void}]{ }\end{DoxyParamCaption})}



Gets the number of threads available for running tasks. 

\begin{DoxyReturn}{Returns}
The number of available threads
\end{DoxyReturn}
Same as doing \mbox{\hyperlink{group__Ecore__Thread__Group_gabad7972818b7fb1346ae7a098cd47220}{ecore\+\_\+thread\+\_\+max\+\_\+get()}} -\/ \mbox{\hyperlink{group__Ecore__Thread__Group_gad7a28588dc26d6af8b6db8abc3ef37ce}{ecore\+\_\+thread\+\_\+active\+\_\+get()}}.

This function may return a negative number only in the case the user changed the maximum number of running threads while other tasks are running. \begin{Desc}
\item[Examples]\par
\mbox{\hyperlink{ecore_thread_example_8c-example}{ecore\+\_\+thread\+\_\+example.\+c}}.\end{Desc}
\mbox{\Hypertarget{group__Ecore__Thread__Group_ga786b2db76a8bc29bca9f6f9cd41bc588}\label{group__Ecore__Thread__Group_ga786b2db76a8bc29bca9f6f9cd41bc588}} 
\index{Ecore Thread functions@{Ecore Thread functions}!ecore\_thread\_name\_set@{ecore\_thread\_name\_set}}
\index{ecore\_thread\_name\_set@{ecore\_thread\_name\_set}!Ecore Thread functions@{Ecore Thread functions}}
\doxysubsubsection{\texorpdfstring{ecore\_thread\_name\_set()}{ecore\_thread\_name\_set()}}
{\footnotesize\ttfamily \mbox{\hyperlink{group__Eina__Types__Group_ga3fe0caf72e93b1bab1ca8ee3ccf3f226}{Eina\+\_\+\+Bool}} ecore\+\_\+thread\+\_\+name\+\_\+set (\begin{DoxyParamCaption}\item[{\mbox{\hyperlink{group__Ecore__Thread__Group_ga0c2e1f8d562ccf80ecc0009ada72496f}{Ecore\+\_\+\+Thread}} $\ast$}]{thread,  }\item[{const char $\ast$}]{name }\end{DoxyParamCaption})}



Sets the name of a given thread for debugging purposes. 

This function will only succeed if called from the named thread.


\begin{DoxyParams}{Parameters}
{\em thread} & The thread context to set the name of \\
\hline
{\em name} & The string to name the thread -\/ this cannot be NULL\\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
EINA\+\_\+\+TRUE if it succeeds setting the name or EINA\+\_\+\+FALSE otherwise.
\end{DoxyReturn}
\begin{DoxySince}{Since}
1.\+26 
\end{DoxySince}


References \mbox{\hyperlink{group__Eina__Types__Group_ga1feb115f8e9913e806e090d9bd5a7301}{EINA\+\_\+\+FALSE}}, \mbox{\hyperlink{group__Eina__Thread__Group_ga099238239a062cf6b33453d599ad0106}{eina\+\_\+thread\+\_\+name\+\_\+set()}}, and \mbox{\hyperlink{group__Eina__Thread__Group_gacd61c43d4ffe9a5b2cb2033b5f77bb4f}{eina\+\_\+thread\+\_\+self()}}.

\mbox{\Hypertarget{group__Ecore__Thread__Group_ga6878f550a9bcc8002c0c709b4b4dca66}\label{group__Ecore__Thread__Group_ga6878f550a9bcc8002c0c709b4b4dca66}} 
\index{Ecore Thread functions@{Ecore Thread functions}!ecore\_thread\_local\_data\_add@{ecore\_thread\_local\_data\_add}}
\index{ecore\_thread\_local\_data\_add@{ecore\_thread\_local\_data\_add}!Ecore Thread functions@{Ecore Thread functions}}
\doxysubsubsection{\texorpdfstring{ecore\_thread\_local\_data\_add()}{ecore\_thread\_local\_data\_add()}}
{\footnotesize\ttfamily \mbox{\hyperlink{group__Eina__Types__Group_ga3fe0caf72e93b1bab1ca8ee3ccf3f226}{Eina\+\_\+\+Bool}} ecore\+\_\+thread\+\_\+local\+\_\+data\+\_\+add (\begin{DoxyParamCaption}\item[{\mbox{\hyperlink{group__Ecore__Thread__Group_ga0c2e1f8d562ccf80ecc0009ada72496f}{Ecore\+\_\+\+Thread}} $\ast$}]{thread,  }\item[{const char $\ast$}]{key,  }\item[{void $\ast$}]{value,  }\item[{\mbox{\hyperlink{group__Eina__Types__Group_gadbac560ba2bca5c61d97bfbb542018f3}{Eina\+\_\+\+Free\+\_\+\+Cb}}}]{cb,  }\item[{\mbox{\hyperlink{group__Eina__Types__Group_ga3fe0caf72e93b1bab1ca8ee3ccf3f226}{Eina\+\_\+\+Bool}}}]{direct }\end{DoxyParamCaption})}



Adds some data to a hash local to the thread. 


\begin{DoxyParams}{Parameters}
{\em thread} & The thread context the data belongs to \\
\hline
{\em key} & The name under which the data will be stored \\
\hline
{\em value} & The data to add \\
\hline
{\em cb} & Function to free the data when removed from the hash \\
\hline
{\em direct} & If {\ttfamily true}, this will not copy the key string (like \mbox{\hyperlink{group__Eina__Hash__Group_ga84a3b957ede675cb03f3c344695c1282}{eina\+\_\+hash\+\_\+direct\+\_\+add()}}) \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
{\ttfamily EINA\+\_\+\+TRUE} on success, {\ttfamily EINA\+\_\+\+FALSE} on failure.
\end{DoxyReturn}
Ecore Thread has a mechanism to share data across several worker functions that run on the same system thread. That is, the data is stored per thread and for a worker function to have access to it, it must be run by the same thread that stored the data.

When there are no more workers pending, the thread will be destroyed along with the internal hash and any data left in it will be freed with the {\ttfamily cb} function given.

This set of functions is useful to share things around several instances of a function when that thing is costly to create and can be reused, but may only be used by one function at a time.

For example, if you have a program doing requisitions to a database, these requisitions can be done in threads so that waiting for the database to respond doesn\textquotesingle{}t block the UI. Each of these threads will run a function, and each function will be dependent on a connection to the database, which may not be able to handle more than one request at a time so for each running function you will need one connection handle. The options then are\+: \begin{DoxyItemize}
\item Each function opens a connection when it\textquotesingle{}s called, does the work and closes the connection when it finishes. This may be costly, wasting a lot of time on resolving hostnames, negotiating permissions and allocating memory. \item Open the connections in the main loop and pass it to the threads using the data pointer. Even worse, it\textquotesingle{}s just as costly as before and now it may even be kept with connections open doing nothing until a thread becomes available to run the function. \item Have a way to share connection handles, so that each instance of the function can check if an available connection exists, and if it doesn\textquotesingle{}t, create one and add it to the pool. When no more connections are needed, they are all closed.\end{DoxyItemize}
The last option is the most efficient, but it requires a lot of work to implement properly. Using thread local data helps to achieve the same result while avoiding doing all the tracking work on your code. The way to use it would be, at the worker function, to ask for the connection with \mbox{\hyperlink{group__Ecore__Thread__Group_gaa99c30f01228217ddd0e510e4e99610b}{ecore\+\_\+thread\+\_\+local\+\_\+data\+\_\+find()}} and if it doesn\textquotesingle{}t exist, then open a new one and save it with \mbox{\hyperlink{group__Ecore__Thread__Group_ga6878f550a9bcc8002c0c709b4b4dca66}{ecore\+\_\+thread\+\_\+local\+\_\+data\+\_\+add()}}. Do the work and forget about the connection handle, when everything is done the function just ends. The next worker to run on that thread will check if a connection exists and find that it does, so the process of opening a new one has been spared. When no more workers exist, the thread is destroyed and the callback used when saving the connection will be called to close it.

This function adds the data {\ttfamily value} to the thread data under the given {\ttfamily key}. No other value in the hash may have the same {\ttfamily key}. If you need to change the value under a {\ttfamily key}, or you don\textquotesingle{}t know if one exists already, you can use \mbox{\hyperlink{group__Ecore__Thread__Group_gac28873eb1d87140dfe1bba4d370ae112}{ecore\+\_\+thread\+\_\+local\+\_\+data\+\_\+set()}}.

Neither {\ttfamily key} nor {\ttfamily value} may be {\ttfamily NULL} and {\ttfamily key} will be copied in the hash, unless {\ttfamily direct} is set, in which case the string used should not be freed until the data is removed from the hash.

The {\ttfamily cb} function will be called when the data in the hash needs to be freed, be it because it got deleted with \mbox{\hyperlink{group__Ecore__Thread__Group_gad3c1d51a24772b885b26486be86c2779}{ecore\+\_\+thread\+\_\+local\+\_\+data\+\_\+del()}} or because {\ttfamily thread} was terminated and the hash destroyed. This parameter may be NULL, in which case {\ttfamily value} needs to be manually freed after removing it from the hash with either \mbox{\hyperlink{group__Ecore__Thread__Group_gad3c1d51a24772b885b26486be86c2779}{ecore\+\_\+thread\+\_\+local\+\_\+data\+\_\+del()}} or \mbox{\hyperlink{group__Ecore__Thread__Group_gac28873eb1d87140dfe1bba4d370ae112}{ecore\+\_\+thread\+\_\+local\+\_\+data\+\_\+set()}}, but it\textquotesingle{}s very unlikely that this is what you want.

This function, and all of the others in the {\ttfamily ecore\+\_\+thread\+\_\+local\+\_\+data} family of functions, can only be called within the worker function running in the thread. Do not call them from the main loop or from a thread other than the one represented by {\ttfamily thread}.

\begin{DoxySeeAlso}{See also}
\mbox{\hyperlink{group__Ecore__Thread__Group_gac28873eb1d87140dfe1bba4d370ae112}{ecore\+\_\+thread\+\_\+local\+\_\+data\+\_\+set()}} 

\mbox{\hyperlink{group__Ecore__Thread__Group_gaa99c30f01228217ddd0e510e4e99610b}{ecore\+\_\+thread\+\_\+local\+\_\+data\+\_\+find()}} 

\mbox{\hyperlink{group__Ecore__Thread__Group_gad3c1d51a24772b885b26486be86c2779}{ecore\+\_\+thread\+\_\+local\+\_\+data\+\_\+del()}} 
\end{DoxySeeAlso}
\begin{Desc}
\item[Examples]\par
\mbox{\hyperlink{ecore_thread_example_8c-example}{ecore\+\_\+thread\+\_\+example.\+c}}.\end{Desc}


References \mbox{\hyperlink{group__Eina__Types__Group_ga1feb115f8e9913e806e090d9bd5a7301}{EINA\+\_\+\+FALSE}}, \mbox{\hyperlink{group__Eina__Hash__Group_ga5e72d0c5397936512407ce8cd66e98d6}{eina\+\_\+hash\+\_\+add()}}, \mbox{\hyperlink{group__Eina__Hash__Group_ga84a3b957ede675cb03f3c344695c1282}{eina\+\_\+hash\+\_\+direct\+\_\+add()}}, and \mbox{\hyperlink{group__Eina__Hash__Group_ga96bbbf394fb34d7e1f57d261de638e69}{eina\+\_\+hash\+\_\+string\+\_\+small\+\_\+new()}}.

\mbox{\Hypertarget{group__Ecore__Thread__Group_gac28873eb1d87140dfe1bba4d370ae112}\label{group__Ecore__Thread__Group_gac28873eb1d87140dfe1bba4d370ae112}} 
\index{Ecore Thread functions@{Ecore Thread functions}!ecore\_thread\_local\_data\_set@{ecore\_thread\_local\_data\_set}}
\index{ecore\_thread\_local\_data\_set@{ecore\_thread\_local\_data\_set}!Ecore Thread functions@{Ecore Thread functions}}
\doxysubsubsection{\texorpdfstring{ecore\_thread\_local\_data\_set()}{ecore\_thread\_local\_data\_set()}}
{\footnotesize\ttfamily void $\ast$ ecore\+\_\+thread\+\_\+local\+\_\+data\+\_\+set (\begin{DoxyParamCaption}\item[{\mbox{\hyperlink{group__Ecore__Thread__Group_ga0c2e1f8d562ccf80ecc0009ada72496f}{Ecore\+\_\+\+Thread}} $\ast$}]{thread,  }\item[{const char $\ast$}]{key,  }\item[{void $\ast$}]{value,  }\item[{\mbox{\hyperlink{group__Eina__Types__Group_gadbac560ba2bca5c61d97bfbb542018f3}{Eina\+\_\+\+Free\+\_\+\+Cb}}}]{cb }\end{DoxyParamCaption})}



Sets some data in the hash local to the given thread. 


\begin{DoxyParams}{Parameters}
{\em thread} & The thread context the data belongs to \\
\hline
{\em key} & The name under which the data will be stored \\
\hline
{\em value} & The data to add \\
\hline
{\em cb} & Function to free the data when removed from the hash\\
\hline
\end{DoxyParams}
If no data exists in the hash under the {\ttfamily key}, this function adds {\ttfamily value} in the hash under the given {\ttfamily key} and returns NULL. The key itself is copied.

If the hash already contains something under {\ttfamily key}, the data will be replaced by {\ttfamily value} and the old value will be returned.

{\ttfamily NULL} will also be returned if either {\ttfamily key} or {\ttfamily value} are {\ttfamily NULL}, or if an error occurred.

This function, and all of the others in the {\ttfamily ecore\+\_\+thread\+\_\+local\+\_\+data} family of functions, can only be called within the worker function running in the thread. Do not call them from the main loop or from a thread other than the one represented by {\ttfamily thread}.

\begin{DoxySeeAlso}{See also}
\mbox{\hyperlink{group__Ecore__Thread__Group_ga6878f550a9bcc8002c0c709b4b4dca66}{ecore\+\_\+thread\+\_\+local\+\_\+data\+\_\+add()}} 

\mbox{\hyperlink{group__Ecore__Thread__Group_gad3c1d51a24772b885b26486be86c2779}{ecore\+\_\+thread\+\_\+local\+\_\+data\+\_\+del()}} 

\mbox{\hyperlink{group__Ecore__Thread__Group_gaa99c30f01228217ddd0e510e4e99610b}{ecore\+\_\+thread\+\_\+local\+\_\+data\+\_\+find()}} 
\end{DoxySeeAlso}


References \mbox{\hyperlink{group__Eina__Hash__Group_gaec07a67481f4a4dc87f08d37a05a26f9}{eina\+\_\+hash\+\_\+set()}}, and \mbox{\hyperlink{group__Eina__Hash__Group_ga96bbbf394fb34d7e1f57d261de638e69}{eina\+\_\+hash\+\_\+string\+\_\+small\+\_\+new()}}.

\mbox{\Hypertarget{group__Ecore__Thread__Group_gaa99c30f01228217ddd0e510e4e99610b}\label{group__Ecore__Thread__Group_gaa99c30f01228217ddd0e510e4e99610b}} 
\index{Ecore Thread functions@{Ecore Thread functions}!ecore\_thread\_local\_data\_find@{ecore\_thread\_local\_data\_find}}
\index{ecore\_thread\_local\_data\_find@{ecore\_thread\_local\_data\_find}!Ecore Thread functions@{Ecore Thread functions}}
\doxysubsubsection{\texorpdfstring{ecore\_thread\_local\_data\_find()}{ecore\_thread\_local\_data\_find()}}
{\footnotesize\ttfamily void $\ast$ ecore\+\_\+thread\+\_\+local\+\_\+data\+\_\+find (\begin{DoxyParamCaption}\item[{\mbox{\hyperlink{group__Ecore__Thread__Group_ga0c2e1f8d562ccf80ecc0009ada72496f}{Ecore\+\_\+\+Thread}} $\ast$}]{thread,  }\item[{const char $\ast$}]{key }\end{DoxyParamCaption})}



Gets data stored in the hash local to the given thread. 


\begin{DoxyParams}{Parameters}
{\em thread} & The thread context the data belongs to \\
\hline
{\em key} & The name under which the data is stored \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
The value under the given key, or {\ttfamily NULL} on error.
\end{DoxyReturn}
Finds and return the data stored in the shared hash under the key {\ttfamily key}.

This function, and all of the others in the {\ttfamily ecore\+\_\+thread\+\_\+local\+\_\+data} family of functions, can only be called within the worker function running in the thread. Do not call them from the main loop or from a thread other than the one represented by {\ttfamily thread}.

\begin{DoxySeeAlso}{See also}
\mbox{\hyperlink{group__Ecore__Thread__Group_ga6878f550a9bcc8002c0c709b4b4dca66}{ecore\+\_\+thread\+\_\+local\+\_\+data\+\_\+add()}} 

ecore\+\_\+thread\+\_\+local\+\_\+data\+\_\+wait() 
\end{DoxySeeAlso}
\begin{Desc}
\item[Examples]\par
\mbox{\hyperlink{ecore_thread_example_8c-example}{ecore\+\_\+thread\+\_\+example.\+c}}.\end{Desc}


References \mbox{\hyperlink{group__Eina__Hash__Group_ga6e9dc02a249e1fcdb64e38e7dc47afb3}{eina\+\_\+hash\+\_\+find()}}.

\mbox{\Hypertarget{group__Ecore__Thread__Group_gad3c1d51a24772b885b26486be86c2779}\label{group__Ecore__Thread__Group_gad3c1d51a24772b885b26486be86c2779}} 
\index{Ecore Thread functions@{Ecore Thread functions}!ecore\_thread\_local\_data\_del@{ecore\_thread\_local\_data\_del}}
\index{ecore\_thread\_local\_data\_del@{ecore\_thread\_local\_data\_del}!Ecore Thread functions@{Ecore Thread functions}}
\doxysubsubsection{\texorpdfstring{ecore\_thread\_local\_data\_del()}{ecore\_thread\_local\_data\_del()}}
{\footnotesize\ttfamily \mbox{\hyperlink{group__Eina__Types__Group_ga3fe0caf72e93b1bab1ca8ee3ccf3f226}{Eina\+\_\+\+Bool}} ecore\+\_\+thread\+\_\+local\+\_\+data\+\_\+del (\begin{DoxyParamCaption}\item[{\mbox{\hyperlink{group__Ecore__Thread__Group_ga0c2e1f8d562ccf80ecc0009ada72496f}{Ecore\+\_\+\+Thread}} $\ast$}]{thread,  }\item[{const char $\ast$}]{key }\end{DoxyParamCaption})}



Deletes from the thread\textquotesingle{}s hash the data corresponding to the given key. 


\begin{DoxyParams}{Parameters}
{\em thread} & The thread context the data belongs to \\
\hline
{\em key} & The name under which the data is stored \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
{\ttfamily EINA\+\_\+\+TRUE} on success, {\ttfamily EINA\+\_\+\+FALSE} on failure.
\end{DoxyReturn}
If there\textquotesingle{}s any data stored associated with {\ttfamily key} in the global hash, this function will remove it from it and return {\ttfamily EINA\+\_\+\+TRUE}. If no data exists or an error occurs, it returns {\ttfamily EINA\+\_\+\+FALSE}.

If the data was added to the hash with a free function, then it will also be freed after removing it from the hash, otherwise it requires to be manually freed by the user, which means that if no other reference to it exists before calling this function, it will result in a memory leak.

This function, and all of the others in the {\ttfamily ecore\+\_\+thread\+\_\+local\+\_\+data} family of functions, can only be called within the worker function running in the thread. Do not call them from the main loop or from a thread other than the one represented by {\ttfamily thread}.

\begin{DoxySeeAlso}{See also}
\mbox{\hyperlink{group__Ecore__Thread__Group_ga6878f550a9bcc8002c0c709b4b4dca66}{ecore\+\_\+thread\+\_\+local\+\_\+data\+\_\+add()}} 
\end{DoxySeeAlso}
\begin{Desc}
\item[Examples]\par
\mbox{\hyperlink{ecore_thread_example_8c-example}{ecore\+\_\+thread\+\_\+example.\+c}}.\end{Desc}


References \mbox{\hyperlink{group__Eina__Types__Group_ga1feb115f8e9913e806e090d9bd5a7301}{EINA\+\_\+\+FALSE}}, and \mbox{\hyperlink{group__Eina__Hash__Group_gadcb1a5cd7604dd23c8c9c1d3c4b773b5}{eina\+\_\+hash\+\_\+del\+\_\+by\+\_\+key()}}.

\mbox{\Hypertarget{group__Ecore__Thread__Group_ga4e9de7492f8400e19ddd157d8cc21811}\label{group__Ecore__Thread__Group_ga4e9de7492f8400e19ddd157d8cc21811}} 
\index{Ecore Thread functions@{Ecore Thread functions}!ecore\_thread\_global\_data\_add@{ecore\_thread\_global\_data\_add}}
\index{ecore\_thread\_global\_data\_add@{ecore\_thread\_global\_data\_add}!Ecore Thread functions@{Ecore Thread functions}}
\doxysubsubsection{\texorpdfstring{ecore\_thread\_global\_data\_add()}{ecore\_thread\_global\_data\_add()}}
{\footnotesize\ttfamily \mbox{\hyperlink{group__Eina__Types__Group_ga3fe0caf72e93b1bab1ca8ee3ccf3f226}{Eina\+\_\+\+Bool}} ecore\+\_\+thread\+\_\+global\+\_\+data\+\_\+add (\begin{DoxyParamCaption}\item[{const char $\ast$}]{key,  }\item[{void $\ast$}]{value,  }\item[{\mbox{\hyperlink{group__Eina__Types__Group_gadbac560ba2bca5c61d97bfbb542018f3}{Eina\+\_\+\+Free\+\_\+\+Cb}}}]{cb,  }\item[{\mbox{\hyperlink{group__Eina__Types__Group_ga3fe0caf72e93b1bab1ca8ee3ccf3f226}{Eina\+\_\+\+Bool}}}]{direct }\end{DoxyParamCaption})}



Adds some data to a hash shared by all threads. 


\begin{DoxyParams}{Parameters}
{\em key} & The name under which the data will be stored \\
\hline
{\em value} & The data to add \\
\hline
{\em cb} & Function to free the data when removed from the hash \\
\hline
{\em direct} & If {\ttfamily true}, this will not copy the key string (like \mbox{\hyperlink{group__Eina__Hash__Group_ga84a3b957ede675cb03f3c344695c1282}{eina\+\_\+hash\+\_\+direct\+\_\+add()}}) \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
{\ttfamily EINA\+\_\+\+TRUE} on success, {\ttfamily EINA\+\_\+\+FALSE} on failure.
\end{DoxyReturn}
Ecore Thread keeps a hash that can be used to share data across several threads, including the main loop one, without having to manually handle mutexes to do so safely.

This function adds the data {\ttfamily value} to this hash under the given {\ttfamily key}. No other value in the hash may have the same {\ttfamily key}. If you need to change the value under a {\ttfamily key}, or you don\textquotesingle{}t know if one exists already, you can use \mbox{\hyperlink{group__Ecore__Thread__Group_gab05209a2ef2f0a16bb69bbdb53a8bcb0}{ecore\+\_\+thread\+\_\+global\+\_\+data\+\_\+set()}}.

Neither {\ttfamily key} nor {\ttfamily value} may be {\ttfamily NULL} and {\ttfamily key} will be copied in the hash, unless {\ttfamily direct} is set, in which case the string used should not be freed until the data is removed from the hash.

The {\ttfamily cb} function will be called when the data in the hash needs to be freed, be it because it got deleted with \mbox{\hyperlink{group__Ecore__Thread__Group_ga8e53feb974331550744cbc2e40dc9132}{ecore\+\_\+thread\+\_\+global\+\_\+data\+\_\+del()}} or because Ecore Thread was shut down and the hash destroyed. This parameter may be NULL, in which case {\ttfamily value} needs to be manually freed after removing it from the hash with either \mbox{\hyperlink{group__Ecore__Thread__Group_ga8e53feb974331550744cbc2e40dc9132}{ecore\+\_\+thread\+\_\+global\+\_\+data\+\_\+del()}} or \mbox{\hyperlink{group__Ecore__Thread__Group_gab05209a2ef2f0a16bb69bbdb53a8bcb0}{ecore\+\_\+thread\+\_\+global\+\_\+data\+\_\+set()}}.

Manually freeing any data that was added to the hash with a {\ttfamily cb} function is likely to produce a segmentation fault, or any other strange happenings, later on in the program.

\begin{DoxySeeAlso}{See also}
\mbox{\hyperlink{group__Ecore__Thread__Group_ga8e53feb974331550744cbc2e40dc9132}{ecore\+\_\+thread\+\_\+global\+\_\+data\+\_\+del()}} 

\mbox{\hyperlink{group__Ecore__Thread__Group_gab05209a2ef2f0a16bb69bbdb53a8bcb0}{ecore\+\_\+thread\+\_\+global\+\_\+data\+\_\+set()}} 

\mbox{\hyperlink{group__Ecore__Thread__Group_ga0eea48ec2cec77087c3f246347f26909}{ecore\+\_\+thread\+\_\+global\+\_\+data\+\_\+find()}} 
\end{DoxySeeAlso}
\begin{Desc}
\item[Examples]\par
\mbox{\hyperlink{ecore_thread_example_8c-example}{ecore\+\_\+thread\+\_\+example.\+c}}.\end{Desc}


References \mbox{\hyperlink{group__Eina__Types__Group_ga1feb115f8e9913e806e090d9bd5a7301}{EINA\+\_\+\+FALSE}}, \mbox{\hyperlink{group__Eina__Hash__Group_ga5e72d0c5397936512407ce8cd66e98d6}{eina\+\_\+hash\+\_\+add()}}, \mbox{\hyperlink{group__Eina__Hash__Group_ga84a3b957ede675cb03f3c344695c1282}{eina\+\_\+hash\+\_\+direct\+\_\+add()}}, and \mbox{\hyperlink{group__Eina__Hash__Group_ga96bbbf394fb34d7e1f57d261de638e69}{eina\+\_\+hash\+\_\+string\+\_\+small\+\_\+new()}}.

\mbox{\Hypertarget{group__Ecore__Thread__Group_gab05209a2ef2f0a16bb69bbdb53a8bcb0}\label{group__Ecore__Thread__Group_gab05209a2ef2f0a16bb69bbdb53a8bcb0}} 
\index{Ecore Thread functions@{Ecore Thread functions}!ecore\_thread\_global\_data\_set@{ecore\_thread\_global\_data\_set}}
\index{ecore\_thread\_global\_data\_set@{ecore\_thread\_global\_data\_set}!Ecore Thread functions@{Ecore Thread functions}}
\doxysubsubsection{\texorpdfstring{ecore\_thread\_global\_data\_set()}{ecore\_thread\_global\_data\_set()}}
{\footnotesize\ttfamily void $\ast$ ecore\+\_\+thread\+\_\+global\+\_\+data\+\_\+set (\begin{DoxyParamCaption}\item[{const char $\ast$}]{key,  }\item[{void $\ast$}]{value,  }\item[{\mbox{\hyperlink{group__Eina__Types__Group_gadbac560ba2bca5c61d97bfbb542018f3}{Eina\+\_\+\+Free\+\_\+\+Cb}}}]{cb }\end{DoxyParamCaption})}



Sets some data in the hash shared by all threads. 


\begin{DoxyParams}{Parameters}
{\em key} & The name under which the data will be stored \\
\hline
{\em value} & The data to add \\
\hline
{\em cb} & Function to free the data when removed from the hash\\
\hline
\end{DoxyParams}
If no data exists in the hash under the {\ttfamily key}, this function adds {\ttfamily value} in the hash under the given {\ttfamily key} and returns NULL. The key itself is copied.

If the hash already contains something under {\ttfamily key}, the data will be replaced by {\ttfamily value} and the old value will be returned.

{\ttfamily NULL} will also be returned if either {\ttfamily key} or {\ttfamily value} are {\ttfamily NULL}, or if an error occurred.

\begin{DoxySeeAlso}{See also}
\mbox{\hyperlink{group__Ecore__Thread__Group_ga4e9de7492f8400e19ddd157d8cc21811}{ecore\+\_\+thread\+\_\+global\+\_\+data\+\_\+add()}} 

\mbox{\hyperlink{group__Ecore__Thread__Group_ga8e53feb974331550744cbc2e40dc9132}{ecore\+\_\+thread\+\_\+global\+\_\+data\+\_\+del()}} 

\mbox{\hyperlink{group__Ecore__Thread__Group_ga0eea48ec2cec77087c3f246347f26909}{ecore\+\_\+thread\+\_\+global\+\_\+data\+\_\+find()}} 
\end{DoxySeeAlso}


References \mbox{\hyperlink{group__Eina__Hash__Group_gaec07a67481f4a4dc87f08d37a05a26f9}{eina\+\_\+hash\+\_\+set()}}, and \mbox{\hyperlink{group__Eina__Hash__Group_ga96bbbf394fb34d7e1f57d261de638e69}{eina\+\_\+hash\+\_\+string\+\_\+small\+\_\+new()}}.

\mbox{\Hypertarget{group__Ecore__Thread__Group_ga0eea48ec2cec77087c3f246347f26909}\label{group__Ecore__Thread__Group_ga0eea48ec2cec77087c3f246347f26909}} 
\index{Ecore Thread functions@{Ecore Thread functions}!ecore\_thread\_global\_data\_find@{ecore\_thread\_global\_data\_find}}
\index{ecore\_thread\_global\_data\_find@{ecore\_thread\_global\_data\_find}!Ecore Thread functions@{Ecore Thread functions}}
\doxysubsubsection{\texorpdfstring{ecore\_thread\_global\_data\_find()}{ecore\_thread\_global\_data\_find()}}
{\footnotesize\ttfamily void $\ast$ ecore\+\_\+thread\+\_\+global\+\_\+data\+\_\+find (\begin{DoxyParamCaption}\item[{const char $\ast$}]{key }\end{DoxyParamCaption})}



Gets data stored in the hash shared by all threads. 


\begin{DoxyParams}{Parameters}
{\em key} & The name under which the data is stored \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
The value under the given key, or {\ttfamily NULL} on error.
\end{DoxyReturn}
Finds and return the data stored in the shared hash under the key {\ttfamily key}.

Keep in mind that the data returned may be used by more than one thread at the same time and no reference counting is done on it by Ecore. Freeing the data or modifying its contents may require additional precautions to be considered, depending on the application\textquotesingle{}s design.

\begin{DoxySeeAlso}{See also}
\mbox{\hyperlink{group__Ecore__Thread__Group_ga4e9de7492f8400e19ddd157d8cc21811}{ecore\+\_\+thread\+\_\+global\+\_\+data\+\_\+add()}} 

\mbox{\hyperlink{group__Ecore__Thread__Group_ga78f34d8bd0806f68a56105662c54e202}{ecore\+\_\+thread\+\_\+global\+\_\+data\+\_\+wait()}} 
\end{DoxySeeAlso}
\begin{Desc}
\item[Examples]\par
\mbox{\hyperlink{ecore_thread_example_8c-example}{ecore\+\_\+thread\+\_\+example.\+c}}.\end{Desc}


References \mbox{\hyperlink{group__Eina__Hash__Group_ga6e9dc02a249e1fcdb64e38e7dc47afb3}{eina\+\_\+hash\+\_\+find()}}.

\mbox{\Hypertarget{group__Ecore__Thread__Group_ga8e53feb974331550744cbc2e40dc9132}\label{group__Ecore__Thread__Group_ga8e53feb974331550744cbc2e40dc9132}} 
\index{Ecore Thread functions@{Ecore Thread functions}!ecore\_thread\_global\_data\_del@{ecore\_thread\_global\_data\_del}}
\index{ecore\_thread\_global\_data\_del@{ecore\_thread\_global\_data\_del}!Ecore Thread functions@{Ecore Thread functions}}
\doxysubsubsection{\texorpdfstring{ecore\_thread\_global\_data\_del()}{ecore\_thread\_global\_data\_del()}}
{\footnotesize\ttfamily \mbox{\hyperlink{group__Eina__Types__Group_ga3fe0caf72e93b1bab1ca8ee3ccf3f226}{Eina\+\_\+\+Bool}} ecore\+\_\+thread\+\_\+global\+\_\+data\+\_\+del (\begin{DoxyParamCaption}\item[{const char $\ast$}]{key }\end{DoxyParamCaption})}



Deletes from the shared hash the data corresponding to the given key. 


\begin{DoxyParams}{Parameters}
{\em key} & The name under which the data is stored \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
{\ttfamily EINA\+\_\+\+TRUE} on success, {\ttfamily EINA\+\_\+\+FALSE} on failure.
\end{DoxyReturn}
If there\textquotesingle{}s any data stored associated with {\ttfamily key} in the global hash, this function will remove it from it and return {\ttfamily EINA\+\_\+\+TRUE}. If no data exists or an error occurs, it returns {\ttfamily EINA\+\_\+\+FALSE}.

If the data was added to the hash with a free function, then it will also be freed after removing it from the hash, otherwise it requires to be manually freed by the user, which means that if no other reference to it exists before calling this function, it will result in a memory leak.

Note, also, that freeing data that other threads may be using will result in a crash, so appropriate care must be taken by the application when that possibility exists.

\begin{DoxySeeAlso}{See also}
\mbox{\hyperlink{group__Ecore__Thread__Group_ga4e9de7492f8400e19ddd157d8cc21811}{ecore\+\_\+thread\+\_\+global\+\_\+data\+\_\+add()}} 
\end{DoxySeeAlso}
\begin{Desc}
\item[Examples]\par
\mbox{\hyperlink{ecore_thread_example_8c-example}{ecore\+\_\+thread\+\_\+example.\+c}}.\end{Desc}


References \mbox{\hyperlink{group__Eina__Types__Group_ga1feb115f8e9913e806e090d9bd5a7301}{EINA\+\_\+\+FALSE}}, and \mbox{\hyperlink{group__Eina__Hash__Group_gadcb1a5cd7604dd23c8c9c1d3c4b773b5}{eina\+\_\+hash\+\_\+del\+\_\+by\+\_\+key()}}.

\mbox{\Hypertarget{group__Ecore__Thread__Group_ga78f34d8bd0806f68a56105662c54e202}\label{group__Ecore__Thread__Group_ga78f34d8bd0806f68a56105662c54e202}} 
\index{Ecore Thread functions@{Ecore Thread functions}!ecore\_thread\_global\_data\_wait@{ecore\_thread\_global\_data\_wait}}
\index{ecore\_thread\_global\_data\_wait@{ecore\_thread\_global\_data\_wait}!Ecore Thread functions@{Ecore Thread functions}}
\doxysubsubsection{\texorpdfstring{ecore\_thread\_global\_data\_wait()}{ecore\_thread\_global\_data\_wait()}}
{\footnotesize\ttfamily void $\ast$ ecore\+\_\+thread\+\_\+global\+\_\+data\+\_\+wait (\begin{DoxyParamCaption}\item[{const char $\ast$}]{key,  }\item[{double}]{seconds }\end{DoxyParamCaption})}



Gets data stored in the shared hash, or wait for it if it doesn\textquotesingle{}t exist. 


\begin{DoxyParams}{Parameters}
{\em key} & The name under which the data is stored \\
\hline
{\em seconds} & The amount of time in seconds to wait for the data. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
The value under the given key, or {\ttfamily NULL} on error.
\end{DoxyReturn}
Finds and return the data stored in the shared hash under the key {\ttfamily key}.

If there\textquotesingle{}s nothing in the hash under the given {\ttfamily key}, the function will block and wait up to {\ttfamily seconds} seconds for some other thread to add it with either \mbox{\hyperlink{group__Ecore__Thread__Group_ga4e9de7492f8400e19ddd157d8cc21811}{ecore\+\_\+thread\+\_\+global\+\_\+data\+\_\+add()}} or \mbox{\hyperlink{group__Ecore__Thread__Group_gab05209a2ef2f0a16bb69bbdb53a8bcb0}{ecore\+\_\+thread\+\_\+global\+\_\+data\+\_\+set()}}. If after waiting there\textquotesingle{}s still no data to get, {\ttfamily NULL} will be returned.

If {\ttfamily seconds} is 0, then no waiting will happen and this function works like \mbox{\hyperlink{group__Ecore__Thread__Group_ga0eea48ec2cec77087c3f246347f26909}{ecore\+\_\+thread\+\_\+global\+\_\+data\+\_\+find()}}. If {\ttfamily seconds} is less than 0, then the function will wait indefinitely.

Keep in mind that the data returned may be used by more than one thread at the same time and no reference counting is done on it by Ecore. Freeing the data or modifying its contents may require additional precautions to be considered, depending on the application\textquotesingle{}s design.

\begin{DoxySeeAlso}{See also}
\mbox{\hyperlink{group__Ecore__Thread__Group_ga4e9de7492f8400e19ddd157d8cc21811}{ecore\+\_\+thread\+\_\+global\+\_\+data\+\_\+add()}} 

\mbox{\hyperlink{group__Ecore__Thread__Group_ga0eea48ec2cec77087c3f246347f26909}{ecore\+\_\+thread\+\_\+global\+\_\+data\+\_\+find()}} 
\end{DoxySeeAlso}


References \mbox{\hyperlink{group__Ecore__Time__Group_ga98f2439b5d3e7114a75bfe2f0c22c4e9}{ecore\+\_\+time\+\_\+get()}}, \mbox{\hyperlink{group__Eina__Tools__Group_ga6bee37244b675b83d6a4f044a7a3d1e8}{EINA\+\_\+\+DBL\+\_\+\+EQ}}, and \mbox{\hyperlink{group__Eina__Hash__Group_ga6e9dc02a249e1fcdb64e38e7dc47afb3}{eina\+\_\+hash\+\_\+find()}}.

