- Main Page
- Related Pages
- Modules
- Namespaces
- Data Structures
- Files
- Examples

Typedefs | Enumerations | Functions
Thread
Eina » Tools

Abstracts platform threads, providing an uniform API. More...

## Typedefs
typedef unsigned long int | Eina_Thread
| Type for a generic thread.
typedef void *(* | Eina_Thread_Cb )(void *data, Eina_Thread t)
| Type for the definition of a thread callback function.
typedef enum _Eina_Thread_Priority | Eina_Thread_Priority

## Enumerations
enum | _Eina_Thread_Priority { EINA_THREAD_URGENT, EINA_THREAD_NORMAL, EINA_THREAD_BACKGROUND, EINA_THREAD_IDLE }

## Functions
Eina_Thread | eina_thread_self (void)
| Return identifier of the current thread. More...
Eina_Bool | eina_thread_equal (Eina_Thread t1, Eina_Thread t2)
| Check if two thread identifiers are the same. More...
Eina_Bool | eina_thread_create (Eina_Thread *t, Eina_Thread_Priority prio, int affinity, Eina_Thread_Cb func, const void *data)
| Create a new thread, setting its priority and affinity. More...
void * | eina_thread_join (Eina_Thread t)
| Join a currently running thread, waiting until it finishes. More...

## Detailed Description

Abstracts platform threads, providing an uniform API.

It's modeled after POSIX THREADS (pthreads), on Linux they are almost 1:1 mapping.

See also
  Lock for mutex/locking abstraction.

Since
  1.8

## Function Documentation

Eina_Thread eina_thread_self | ( | void |  | ) |

Return identifier of the current thread.

Returns
  identifier of current thread.

Since
  1.8

Eina_Bool eina_thread_equal | ( | Eina_Thread | t1,
|  | Eina_Thread | t2
| ) |  |

Check if two thread identifiers are the same.

Parameters

  t1 | first thread identifier to compare.
  t2 | second thread identifier to compare.

Returns
  EINA_TRUE if they are equal, EINA_FALSE otherwise.

Since
  1.8

Eina_Bool eina_thread_create | ( | Eina_Thread * | t,
|  | Eina_Thread_Priority | prio,
|  | int | affinity,
|  | Eina_Thread_Cb | func,
|  | const void * | data
| ) |  |

Create a new thread, setting its priority and affinity.

Parameters

  t[out] | where to return the thread identifier. Must not be `NULL`.
  prio | thread priority to use, usually #EINA_THREAD_BACKGROUND
  affinity | thread affinity to use. To not set affinity use `-1`.
  func | function to run in the thread. Must not be `NULL`.
  data | context data to provide to func as first argument.

Returns
  EINA_TRUE if thread was created, EINA_FALSE on errors.

Since
  1.8

References EINA_FALSE, and EINA_TRUE.

Referenced by efl::eina::thread::thread().

void* eina_thread_join | ( | Eina_Thread | t | ) |

Join a currently running thread, waiting until it finishes.

This function will block the current thread until t finishes. The returned value is the one returned by t `func()` and may be `NULL` on errors. See Error to identify problems.

Parameters

  t | thread identifier to wait.

Returns
  value returned by t creation function `func()` or `NULL` on errors. Check error with Error.

Since
  1.8

Referenced by efl::eina::thread::join().