The Eina lock libraries provide thread locking and sychronization capabilities similar to POISIX threads (pthreads), but it takes care of the platform specific details so you don't have to. More...
Macros | |
| #define | EINA_MAIN_LOOP_CHECK_RETURN_VAL(val) |
| The macro doesn't do anything unless EINA_HAVE_DEBUG_THREADS is defined. More... | |
| #define | EINA_MAIN_LOOP_CHECK_RETURN |
| The macro doesn't do anything unless EINA_HAVE_DEBUG_THREADS is defined. | |
Typedefs | |
| typedef void(* | Eina_TLS_Delete_Cb )(void *ptr) |
| Type definition for deallocation callbacks for thread level sotrage data. More... | |
| typedef struct _Eina_Barrier | Eina_Barrier |
| An opaque type for working with barrier locks. | |
| typedef struct _Eina_Lock | Eina_Lock |
| An opaque type for working with locks. | |
| typedef struct _Eina_Condition | Eina_Condition |
| An opaque type that represents a condition variable. | |
| typedef struct _Eina_RWLock | Eina_RWLock |
| An opaque type for working with read/write locks. | |
| typedef pthread_key_t | Eina_TLS |
| An opaque type for working with thread level storage. | |
| typedef sem_t | Eina_Semaphore |
| An opaque type for working with semaphores. | |
| typedef Eina_Lock | Eina_Spinlock |
| An opaque type for working with spinlocks. | |
Enumerations | |
| enum | Eina_Lock_Result { EINA_LOCK_FAIL = EINA_FALSE, EINA_LOCK_SUCCEED = EINA_TRUE, EINA_LOCK_DEADLOCK } |
| Return codes for lock operations. More... | |
Functions | |
| static Eina_Bool | eina_lock_new (Eina_Lock *mutex) |
| Initializes a new Eina_Lock. More... | |
| static void | eina_lock_free (Eina_Lock *mutex) |
| Deallocates an Eina_Lock. More... | |
| static Eina_Lock_Result | eina_lock_take (Eina_Lock *mutex) |
| Attempts to take a lock. More... | |
| static Eina_Lock_Result | eina_lock_take_try (Eina_Lock *mutex) |
| Attempts to take a lock. More... | |
| static Eina_Lock_Result | eina_lock_release (Eina_Lock *mutex) |
| Releases a lock. More... | |
| static void | eina_lock_debug (const Eina_Lock *mutex) |
| Print debug information about a lock. More... | |
| static Eina_Bool | eina_condition_new (Eina_Condition *cond, Eina_Lock *mutex) |
| Initializes a new condition variable. More... | |
| static void | eina_condition_free (Eina_Condition *cond) |
| Deallocates a condition variable. More... | |
| static Eina_Bool | eina_condition_wait (Eina_Condition *cond) |
| Causes a thread to wait until signaled by the condition. More... | |
| static Eina_Bool | eina_condition_timedwait (Eina_Condition *cond, double t) |
| Causes a thread to wait until signaled by the condition or a timeout is reached. More... | |
| static Eina_Bool | eina_condition_broadcast (Eina_Condition *cond) |
| Signal all threads waiting for a condition. More... | |
| static Eina_Bool | eina_condition_signal (Eina_Condition *cond) |
| Signal a thread waiting for a condition. More... | |
| static Eina_Bool | eina_rwlock_new (Eina_RWLock *mutex) |
| Initializes a new Eina_RWLock. More... | |
| static void | eina_rwlock_free (Eina_RWLock *mutex) |
| Deallocates an Eina_RWLock. More... | |
| static Eina_Lock_Result | eina_rwlock_take_read (Eina_RWLock *mutex) |
| Attempts to take a read lock. More... | |
| static Eina_Lock_Result | eina_rwlock_take_write (Eina_RWLock *mutex) |
| Attempts to take a write lock. More... | |
| static Eina_Lock_Result | eina_rwlock_release (Eina_RWLock *mutex) |
| Releases a lock. More... | |
| static Eina_Bool | eina_tls_new (Eina_TLS *key) |
| Initializes a new Eina_TLS, or thread level storage, to store thread specific data. More... | |
| static Eina_Bool | eina_tls_cb_new (Eina_TLS *key, Eina_TLS_Delete_Cb delete_cb) |
| Initializes a new Eina_TLS, or thread level storage, to store thread specific data. More... | |
| static void | eina_tls_free (Eina_TLS key) |
| Frees an allocated Eina_TLS. More... | |
| static void * | eina_tls_get (Eina_TLS key) |
| Gets the value in Eina_TLS for this thread. More... | |
| static Eina_Bool | eina_tls_set (Eina_TLS key, const void *data) |
| Sets the value in Eina_TLS for this thread. More... | |
| static Eina_Bool | eina_semaphore_new (Eina_Semaphore *sem, int count_init) |
| Initializes a new Eina_Semaphore. More... | |
| static Eina_Bool | eina_semaphore_free (Eina_Semaphore *sem) |
| Frees an allocated Eina_Semaphore. More... | |
| static Eina_Bool | eina_semaphore_lock (Eina_Semaphore *sem) |
| Gets a lock on an Eina_Semaphore. More... | |
| static Eina_Bool | eina_semaphore_release (Eina_Semaphore *sem, int count_release) |
| Releases a lock on an Eina_Semaphore. More... | |
| static Eina_Bool | eina_barrier_new (Eina_Barrier *barrier, int needed) |
| Initializes a new Eina_Barrier. More... | |
| static void | eina_barrier_free (Eina_Barrier *barrier) |
| Frees an allocated Eina_Barrier. More... | |
| static Eina_Bool | eina_barrier_wait (Eina_Barrier *barrier) |
Increments the count of threads that are waiting on barrier. More... | |
| static Eina_Bool | eina_spinlock_new (Eina_Spinlock *spinlock) |
| Initializes a new Eina_Spinlock. More... | |
| static Eina_Lock_Result | eina_spinlock_take (Eina_Spinlock *spinlock) |
| Attempts to take a spinlock. More... | |
| static Eina_Lock_Result | eina_spinlock_take_try (Eina_Spinlock *spinlock) |
| Attempts to take a spinlock. More... | |
| static Eina_Lock_Result | eina_spinlock_release (Eina_Spinlock *spinlock) |
| Releases a spinlock. More... | |
| static void | eina_spinlock_free (Eina_Spinlock *spinlock) |
| Deallocates an Eina_Spinlock. More... | |
Variables | |
| Eina_Error | EINA_ERROR_NOT_MAIN_LOOP |
| A type definition for warning that a function was called from somewhere other than the EFL main loop. More... | |
The Eina lock libraries provide thread locking and sychronization capabilities similar to POISIX threads (pthreads), but it takes care of the platform specific details so you don't have to.
If you know how pthreads work, this library will look familiar to you. If you are not familiar with pthreads, a good overview is available here
The Eina lock functions are grouped into several categories to handle different thread locking and sychronization methods:
| #define EINA_MAIN_LOOP_CHECK_RETURN_VAL | ( | val | ) |
The macro doesn't do anything unless EINA_HAVE_DEBUG_THREADS is defined.
| val | The value to be returned. |
Referenced by _ecore_timer_interval_get(), _ecore_timer_pending_get(), ecore_animator_del(), ecore_animator_frametime_get(), ecore_animator_source_get(), ecore_event_add(), ecore_event_current_event_get(), ecore_event_current_type_get(), ecore_event_del(), ecore_event_filter_add(), ecore_event_filter_del(), ecore_event_handler_add(), ecore_event_handler_data_get(), ecore_event_handler_data_set(), ecore_event_handler_del(), ecore_event_type_new(), ecore_exe_cmd_get(), ecore_exe_data_get(), ecore_exe_data_set(), ecore_exe_event_data_get(), ecore_exe_flags_get(), ecore_exe_free(), ecore_exe_pid_get(), ecore_exe_pipe_run(), ecore_exe_run(), ecore_exe_run_priority_get(), ecore_exe_send(), ecore_exe_tag_get(), ecore_idle_enterer_del(), ecore_idle_exiter_del(), ecore_idler_del(), ecore_job_del(), ecore_main_fd_handler_active_get(), ecore_main_fd_handler_add(), ecore_main_fd_handler_del(), ecore_main_fd_handler_fd_get(), ecore_main_fd_handler_file_add(), ecore_main_loop_iterate_may_block(), ecore_main_loop_select_func_get(), ecore_pipe_del(), ecore_poller_del(), ecore_poller_poll_interval_get(), ecore_thread_active_get(), ecore_thread_feedback_run(), ecore_thread_max_get(), ecore_thread_pending_feedback_get(), ecore_thread_pending_get(), ecore_thread_pending_total_get(), ecore_thread_run(), ecore_throttle_get(), ecore_timer_add(), ecore_timer_del(), and ecore_timer_precision_get().
| typedef void(* Eina_TLS_Delete_Cb)(void *ptr) |
Type definition for deallocation callbacks for thread level sotrage data.
A simple function pointer.
| enum Eina_Lock_Result |
Initializes a new Eina_Lock.
This function initializes an Eina_Lock with appropriate values. These values are platform dependent as is the structure of the Eina_Lock itself.
| mutex | The Eina_Lock structure to be initialized. |
Referenced by ecore_init(), ecore_main_loop_thread_safe_call_sync(), ecore_thread_main_loop_begin(), eet_init(), eina_file_open(), eina_file_virtualize(), and eio_init().
|
inlinestatic |
Deallocates an Eina_Lock.
This function deallocates an Eina_Lock and does any platform dependent cleanup that is required.
| mutex | The Eina_Lock structure to be deallocated. |
Referenced by ecore_shutdown(), eet_shutdown(), and eio_shutdown().
|
inlinestatic |
Attempts to take a lock.
This function attempts to gain a lock on the indicated Eina_Lock. If the underlying Eina_Lock is locked already, this call will block until the lock is released. This is appropriate in many cases, but consider using eina_lock_take_try if you don't need to block.
| mutex | The Eina_Lock to take. |
Referenced by ecore_fork_reset(), ecore_main_loop_thread_safe_call_sync(), ecore_thread_main_loop_begin(), ecore_thread_main_loop_end(), efreet_desktop_category_add(), efreet_desktop_category_del(), efreet_desktop_free(), efreet_desktop_new(), efreet_desktop_ref(), efreet_desktop_x_field_del(), efreet_desktop_x_field_set(), efreet_util_path_to_file_id(), eina_file_close(), eina_file_dup(), eina_file_flush(), eina_file_map_all(), eina_file_map_faulted(), eina_file_map_free(), eina_file_map_lines(), eina_file_map_new(), eina_file_map_populate(), eina_file_open(), eina_file_virtual_map_all(), eina_file_virtual_map_free(), eina_file_virtual_map_new(), eina_tmpstr_add_length(), eina_tmpstr_del(), eina_tmpstr_strlen(), and eio_memory_burst_limit_set().
|
inlinestatic |
Attempts to take a lock.
This function attempts to gain a lock on the indicated Eina_Lock. Identical to eina_lock_take, but returns immediately if the lock is already taken.
| mutex | The Eina_Lock to take. |
|
inlinestatic |
Releases a lock.
This function will release the lock on the indicated Eina_Lock. If successful, and EINA_HAVE_DEBUG_THREADS is defined, mutex is updated and information about the locking process is removed (e.g. thread number and backtrace for POSIX).
| mutex | The Eina_Lock to release. |
Referenced by ecore_fork_reset(), ecore_main_loop_thread_safe_call_sync(), ecore_thread_main_loop_begin(), ecore_thread_main_loop_end(), efreet_desktop_category_add(), efreet_desktop_category_del(), efreet_desktop_free(), efreet_desktop_new(), efreet_desktop_ref(), efreet_desktop_x_field_del(), efreet_desktop_x_field_set(), efreet_util_path_to_file_id(), eina_file_close(), eina_file_dup(), eina_file_flush(), eina_file_map_all(), eina_file_map_faulted(), eina_file_map_free(), eina_file_map_lines(), eina_file_map_new(), eina_file_map_populate(), eina_file_open(), eina_file_virtual_map_all(), eina_file_virtual_map_free(), eina_file_virtual_map_new(), eina_tmpstr_add_length(), eina_tmpstr_del(), eina_tmpstr_strlen(), and eio_memory_burst_limit_set().
|
inlinestatic |
Print debug information about a lock.
This function will print debug information for mutex. The information is platform dependant. On POSIX systems it will print the address of mutex, lock state, thread number and a backtrace.
| mutex | The Eina_Lock to print debug info for. |
Referenced by eina_threads_shutdown().
|
inlinestatic |
Initializes a new condition variable.
This function initializes an Eina_Condition structure and associates it with an existing lock.
Condition variables are used to coordinate actions between threads. See Condition Varable Overview for an introduction to condition variables and their use.
| cond | The condition variable to create. |
| mutex | The _Eina_Lock structure that controls access to this condition variable. |
Referenced by ecore_init(), ecore_main_loop_thread_safe_call_sync(), ecore_thread_main_loop_begin(), and eio_init().
|
inlinestatic |
Deallocates a condition variable.
This function deallocates a condition variable and does any platform dependent cleanup that is required.
| cond | The condition variable to be deallocated. |
Referenced by ecore_shutdown(), and eio_shutdown().
|
inlinestatic |
Causes a thread to wait until signaled by the condition.
This function makes a thread block until a signal is sent to it via cond.
| cond | The Eina_Condition upon which the thread will wait. |
Referenced by ecore_main_loop_thread_safe_call_sync(), ecore_thread_main_loop_begin(), and ecore_thread_main_loop_end().
|
inlinestatic |
Causes a thread to wait until signaled by the condition or a timeout is reached.
This function makes a thread block until either a signal is sent to it via cond or t seconds have passed.
| cond | The Eina_Condition upon which the thread will wait. |
| t | The maximum amount of time to wait, in seconds. |
|
inlinestatic |
Signal all threads waiting for a condition.
This function sends a signal to all the threads waiting on the condition cond. If you know for sure that there is only one thread waiting, use eina_condition_signal instead to gain a little optimization.
| cond | The Eina_Condition that will signal all its waiting threads. |
Referenced by ecore_thread_main_loop_end(), and eio_memory_burst_limit_set().
|
inlinestatic |
Signal a thread waiting for a condition.
This function sends a signal to a thread waiting on the condition cond. If you do not know for sure that there is only one thread waiting, use eina_condition_broadcast instead.
If there is more than one thread waiting on this condition, one of them will be signalled, but which one is undefined.
| cond | The Eina_Condition that will signal its waiting thread. |
|
inlinestatic |
Initializes a new Eina_RWLock.
This function initializes an Eina_RWLock with appropriate values. These values are platform dependent as is the structure of the Eina_RWLock itself.
| mutex | The Eina_RWLock to be initialized. |
|
inlinestatic |
Deallocates an Eina_RWLock.
This function deallocates an Eina_RWLock and does any platform dependent cleanup that is required.
| mutex | The Eina_RWLock structure to be deallocated. |
|
inlinestatic |
Attempts to take a read lock.
This function attempts to gain a read lock on the indicated Eina_RWLock. If the Eina_RWLock is write locked, this call will block until the lock is released.
| mutex | The Eina_RWLock to take. |
|
inlinestatic |
Attempts to take a write lock.
This function attempts to gain a write lock on the indicated Eina_RWLock. If the Eina_RWLock is locked for reading or writing, this call will block until the lock is released.
| mutex | The Eina_RWLock to take. |
|
inlinestatic |
Releases a lock.
This function will release the lock on the indicated Eina_RWLock.
| mutex | The Eina_RWLock to release. |
Initializes a new Eina_TLS, or thread level storage, to store thread specific data.
This function initializes an Eina_TLS with key but does not set a callback to deallocate key when the thread exits. The implementation is platform dependent as is the structure of the Eina_TLS itself.
| key | The Eina_TLS to be initialized. |
|
inlinestatic |
Initializes a new Eina_TLS, or thread level storage, to store thread specific data.
This function initializes an Eina_TLS with key and sets a callback to deallocate key when the thread exits. The implementation is platform dependent as is the structure of the Eina_TLS itself.
| key | The Eina_TLS to be initialized. |
| delete_cb | A pointer to a function that will deallocate key. |
|
inlinestatic |
Frees an allocated Eina_TLS.
This function frees the Eina_TLS key. The implementation is platform dependent.
| key | The Eina_TLS to be freed. |
|
inlinestatic |
Gets the value in Eina_TLS for this thread.
This function gets a pointer to the data associated with Eina_TLS key for this thread. The implementation is platform dependent.
| key | The Eina_TLS to be retrieved. |
key. Referenced by eina_error_get().
Sets the value in Eina_TLS for this thread.
This function sets the value associated with key to the pointer to the data data. The implementation is platform dependent.
| key | The Eina_TLS to be set. |
| data | A pointer to the data to be stored. |
Referenced by eina_error_set().
|
inlinestatic |
Initializes a new Eina_Semaphore.
This function initializes an unnamed Eina_Semaphore with appropriate values. These values are platform dependent.
Be aware that the behavior of the parameter count_init differs by platform.
| sem | The Eina_Semaphore to be initialized. |
| count_init | Behavior is platofrm specific. See above. |
|
inlinestatic |
Frees an allocated Eina_Semaphore.
This function frees the Eina_Semaphore sem. The implementation is platform dependent.
| sem | The Eina_Semaphore to be freed. |
|
inlinestatic |
Gets a lock on an Eina_Semaphore.
This function locks the Eina_Semaphore sem. The implementation is platform dependent.
| sem | The Eina_Semaphore to lock. |
|
inlinestatic |
Releases a lock on an Eina_Semaphore.
This function releases a lock on the Eina_Semaphore sem. The implementation is platform dependent.
| sem | The Eina_Semaphore to release. |
| count_release | Not used. |
|
inlinestatic |
Initializes a new Eina_Barrier.
This function initializes a new Eina_Barrier. It will set the needed flag to the value of needed, set the barrier's count member to 0 and will create new Eina_Lock and Eina_Condition objects for the barrier.
| barrier | The Eina_Barrier to be initialized. |
| needed | The number of thread waits that will cause this barrier to be reset. |
|
inlinestatic |
Frees an allocated Eina_Barrier.
This function frees the Eina_Barrier barrier.
| barrier | The Eina_Barrier to be freed. |
|
inlinestatic |
Increments the count of threads that are waiting on barrier.
When the count of threads reaches the needed value for the barrier, all waiting threads will be notified via eina_condition_broadcast.
| barrier | The Eina_Barrier to be incremented. |
|
inlinestatic |
Initializes a new Eina_Spinlock.
This function initializes a new Eina_Spinlock, if spinlocks are available. If spinlocks are not avialable, it will create a new Eina_Lock.
| spinlock | The Eina_Spinlock to be initialized. |
Referenced by eio_init().
|
inlinestatic |
Attempts to take a spinlock.
This function attempts to gain a lock on the indicated Eina_Spinlock. If the underlying Eina_Spinlock is locked already, this call will block until the lock is released. This is appropriate in many cases, but consider using eina_spinlock_take_try if you don't need to block.
| spinlock | The Eina_Spinlock to take. |
Referenced by eet_dictionary_string_check(), eina_stringshare_add_length(), eina_stringshare_del(), eina_stringshare_ref(), and evas_async_events_put().
|
inlinestatic |
Attempts to take a spinlock.
This function attempts to gain a lock on the indicated Eina_Spinlock. Identical to eina_lock_take, but returns immediately if the lock is already taken.
| spinlock | The Eina_Spinlock to take. |
|
inlinestatic |
Releases a spinlock.
This function will release the lock on the indicated Eina_Spinlock. If successful, and EINA_HAVE_DEBUG_THREADS is defined, mutex is updated and information about the locking process is removed (e.g. thread number and backtrace for POSIX).
| spinlock | The Eina_Spinlock to release. |
Referenced by eet_dictionary_string_check(), eina_stringshare_add_length(), eina_stringshare_del(), eina_stringshare_ref(), and evas_async_events_put().
|
inlinestatic |
Deallocates an Eina_Spinlock.
This function deallocates an Eina_Spinlock and does any platform dependent cleanup that is required.
| spinlock | The Eina_Spinlock to be deallocated. |
Referenced by eio_shutdown().
| Eina_Error EINA_ERROR_NOT_MAIN_LOOP |
A type definition for warning that a function was called from somewhere other than the EFL main loop.