Tizen Native API
7.0
|
Abstracts platform threads, providing a uniform API. It's modeled after POSIX THREADS (pthreads), on Linux they are almost 1:1 mapping.
- See also:
- Eina_Lock_Group for mutex/locking abstraction.
- Since (EFL) :
- 1.8
Functions | |
Eina_Thread | eina_thread_self (void) |
Returns identifier of the current thread. | |
Eina_Bool | eina_thread_equal (Eina_Thread t1, Eina_Thread t2) |
Checks if two thread identifiers are the same. | |
Eina_Bool | eina_thread_create (Eina_Thread *t, Eina_Thread_Priority prio, int affinity, Eina_Thread_Cb func, const void *data) |
Creates a new thread, setting its priority and affinity. | |
void * | eina_thread_join (Eina_Thread t) |
Joins a currently running thread, waiting until it finishes. | |
Eina_Bool | eina_thread_name_set (Eina_Thread t, const char *name) |
Sets the name of a given thread for debugging purposes. | |
Typedefs | |
typedef uintptr_t | Eina_Thread |
typedef void *(* | Eina_Thread_Cb )(void *data, Eina_Thread t) |
typedef enum _Eina_Thread_Priority | Eina_Thread_Priority |
typedef void *(* | Eina_Thread_Cancellable_Run_Cb )(void *data) |
Defines | |
#define | EINA_THREAD_CLEANUP_PUSH(cleanup, data) pthread_cleanup_push(cleanup, data) |
Pushes a cleanup function to be executed when the thread is canceled. | |
#define | EINA_THREAD_CLEANUP_POP(exec_cleanup) pthread_cleanup_pop(exec_cleanup) |
Pops a cleanup function to be executed when the thread is canceled. |
Define Documentation
#define EINA_THREAD_CLEANUP_POP | ( | exec_cleanup | ) | pthread_cleanup_pop(exec_cleanup) |
Pops a cleanup function to be executed when the thread is canceled.
This macro will remove a previously pushed cleanup function, thus if the thread is canceled with eina_thread_cancel() and the thread was previously marked as cancellable with eina_thread_cancellable_set(), that cleanup won't be executed anymore.
It must be paired with EINA_THREAD_CLEANUP_PUSH() in the same code block as they will expand to do {} while ()!
- Note:
- If the block within EINA_THREAD_CLEANUP_PUSH() and EINA_THREAD_CLEANUP_POP() returns, the cleanup callback will not be executed even if exec_cleanup is EINA_TRUE! To avoid problems prefer to use eina_thread_cancellable_run()!
- Parameters:
-
[in] exec_cleanup if EINA_TRUE, the function registered with EINA_THREAD_CLEANUP_PUSH() will be executed.
- See also:
- eina_thread_cancellable_run()
- Since (EFL) :
- 1.19
#define EINA_THREAD_CLEANUP_PUSH | ( | cleanup, | |
data | |||
) | pthread_cleanup_push(cleanup, data) |
Pushes a cleanup function to be executed when the thread is canceled.
This macro will schedule a function cleanup(data) to be executed if the thread is canceled with eina_thread_cancel() and the thread was previously marked as cancellable with eina_thread_cancellable_set().
It must be paired with EINA_THREAD_CLEANUP_POP() in the same code block as they will expand to do {} while ()!
The cleanup function may also be executed if EINA_THREAD_CLEANUP_POP(EINA_TRUE) is used.
- Note:
- If the block within EINA_THREAD_CLEANUP_PUSH() and EINA_THREAD_CLEANUP_POP() returns, the cleanup callback will not be executed! To avoid problems prefer to use eina_thread_cancellable_run()!
- Parameters:
-
[in] cleanup The function to execute on cancellation. [in] data The context to give to cleanup function.
- See also:
- eina_thread_cancellable_run()
- Since (EFL) :
- 1.19
Typedef Documentation
Type for a generic thread.
Type for the definition of a cancellable callback to run.
- Since (EFL) :
- 1.19
Type for the definition of a thread callback function
Type to enumerate different thread priorities
Enumeration Type Documentation
Function Documentation
Eina_Bool eina_thread_create | ( | Eina_Thread * | t, |
Eina_Thread_Priority | prio, | ||
int | affinity, | ||
Eina_Thread_Cb | func, | ||
const void * | data | ||
) |
Creates a new thread, setting its priority and affinity.
- Parameters:
-
[out] t where to return the thread identifier. Must not be NULL
.[in] prio thread priority to use, usually EINA_THREAD_BACKGROUND [in] affinity thread affinity to use. To not set affinity use -1
.[in] func function to run in the thread. Must not be NULL
.[in] data context data to provide to func as first argument.
- Returns:
- EINA_TRUE if thread was created, EINA_FALSE on errors.
- Since (EFL) :
- 1.8
- Since :
- 3.0
Eina_Bool eina_thread_equal | ( | Eina_Thread | t1, |
Eina_Thread | t2 | ||
) |
Checks if two thread identifiers are the same.
- Parameters:
-
[in] t1 first thread identifier to compare. [in] t2 second thread identifier to compare.
- Returns:
- EINA_TRUE if they are equal, EINA_FALSE otherwise.
- Since (EFL) :
- 1.8
- Since :
- 3.0
void* eina_thread_join | ( | Eina_Thread | t | ) |
Joins 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:
-
[in] t thread identifier to wait.
- Returns:
- value returned by t creation function
func()
orNULL
on errors. Check error with Error. If the thread was canceled, it will return EINA_THREAD_JOIN_CANCELED.
- Since (EFL) :
- 1.8
- Since :
- 3.0
Eina_Bool eina_thread_name_set | ( | Eina_Thread | t, |
const char * | name | ||
) |
Sets the name of a given thread for debugging purposes.
This maps to the pthread_setname_np() GNU extension or similar if available. The name may be limited in size (possibly 16 characters including the null byte terminator). This is useful for debugging to name a thread so external tools can display a meaningful name attached to the thread.
- Parameters:
-
[in] t thread to set the name of [in] name a string to name the thread - this cannot be NULL
- Returns:
- EINA_TRUE if it succeeds in setting the name or EINA_FALSE otherwise.
- Since (EFL) :
- 1.16
- Since :
- 3.0
Eina_Thread eina_thread_self | ( | void | ) |
Returns identifier of the current thread.
- Returns:
- identifier of current thread.
- Since (EFL) :
- 1.8
- Since :
- 3.0
Variable Documentation
const void* EINA_THREAD_JOIN_CANCELED |
The return value of eina_thread_join() if it was canceled with eina_thread_cancel().
A thread must be explicitly flagged as cancellable with eina_thread_cancellable_set(), by default it's not and this value shouldn't be returned.
- See also:
- eina_thread_join()
- Since (EFL) :
- 1.19