Macros | Typedefs | Enumerations | Functions | Variables
Lock

This group provides thread locking and synchronization capabilities. 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)
 A callback type for deallocation of thread level sotrage data.
 

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 if possible. 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 if possible. 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

EAPI 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.
 

Detailed Description

This group provides thread locking and synchronization 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:

Macro Definition Documentation

◆ EINA_MAIN_LOOP_CHECK_RETURN_VAL

#define EINA_MAIN_LOOP_CHECK_RETURN_VAL (   val)

Enumeration Type Documentation

◆ Eina_Lock_Result

Return codes for lock operations.

Enumerator
EINA_LOCK_FAIL 

Indicates that the lock operation failed.

EINA_LOCK_SUCCEED 

Indicates that the lock operation succeeded.

EINA_LOCK_DEADLOCK 

Indicates that the lock is deadlocked.

Function Documentation

◆ eina_lock_new()

static Eina_Bool eina_lock_new ( Eina_Lock *  mutex)
inlinestatic

Initializes a new #Eina_Lock.

Parameters
[in]mutexThe #Eina_Lock structure to be initialized
Returns
EINA_TRUE on success, EINA_FALSE otherwise

This function initializes an #Eina_Lock with appropriate values. These values are platform dependent as is the structure of the #Eina_Lock itself.

See also
eina_lock_free()
Examples:
ecore_thread_example.c.

Referenced by ecore_init(), ecore_main_loop_thread_safe_call_sync(), ecore_thread_main_loop_begin(), eet_init(), eio_init(), efl::eina::mutex::mutex(), and efl::eina::thread::thread().

◆ eina_lock_free()

static void eina_lock_free ( Eina_Lock *  mutex)
inlinestatic

Deallocates an #Eina_Lock.

Parameters
[in]mutexThe #Eina_Lock structure to be deallocated

This function deallocates an #Eina_Lock allocated by eina_lock_new() and does any platform dependent cleanup that is required.

See also
eina_lock_new()
Examples:
ecore_thread_example.c.

Referenced by elm_store_free(), emotion_shutdown(), evas_async_events_put(), evas_free(), and efl::eina::mutex::~mutex().

◆ eina_lock_take()

static Eina_Lock_Result eina_lock_take ( Eina_Lock *  mutex)
inlinestatic

Attempts to take a lock.

Parameters
[in]mutexThe #Eina_Lock to take
Returns
Returns EINA_LOCK_SUCCEED on success. If the operation fails because a deadlock condition exists, it returns EINA_LOCK_DEADLOCK. If some other condition causes the take to fail, EINA_LOCK_FAIL is returned.

This function attempts to gain a lock on the indicated #Eina_Lock. If the underlying #Eina_Lock is locked already, this call can be blocked 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.

See also
eina_lock_take_try()
eina_lock_release()
Examples:
ecore_thread_example.c.

Referenced by ecore_fork_reset(), ecore_main_loop_thread_safe_call_sync(), ecore_thread_main_loop_begin(), ecore_thread_main_loop_end(), efreet_desktop_free(), eina_file_dup(), eina_file_flush(), eina_file_virtual_map_all(), eina_file_virtual_map_free(), eina_file_virtual_map_new(), eina_tmpstr_add_length(), eina_tmpstr_del(), eina_tmpstr_len(), eina_tmpstr_manage_new_length(), eio_memory_burst_limit_set(), elm_store_free(), emotion_shutdown(), evas_async_events_put(), and efl::eina::mutex::lock().

◆ eina_lock_take_try()

static Eina_Lock_Result eina_lock_take_try ( Eina_Lock *  mutex)
inlinestatic

Attempts to take a lock if possible.

Parameters
[in]mutexThe #Eina_Lock to take
Returns
Returns EINA_LOCK_SUCCEED on success. If the operation fails because a deadlock condition exists, it returns EINA_LOCK_DEADLOCK. If some other condition causes the take to fail, EINA_LOCK_FAIL is returned.

This function attempts to gain a lock on the indicated #Eina_Lock. Identical eina_lock_take(), but returns immediately if the lock is already taken.

See also
eina_lock_take()
eina_lock_release()
Examples:
ecore_thread_example.c.

Referenced by efl::eina::mutex::try_lock().

◆ eina_lock_release()

static Eina_Lock_Result eina_lock_release ( Eina_Lock *  mutex)
inlinestatic

Releases a lock.

Parameters
[in]mutexThe #Eina_Lock to release
Returns
Returns EINA_LOCK_SUCCEED on success. If it fails, EINA_LOCK_FAIL is returned.

This function releases 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).

See also
eina_lock_take()
eina_lock_take_try()
Examples:
ecore_thread_example.c.

Referenced by ecore_fork_reset(), ecore_main_loop_thread_safe_call_sync(), ecore_thread_main_loop_begin(), ecore_thread_main_loop_end(), efreet_desktop_free(), eina_file_dup(), eina_file_flush(), eina_file_virtual_map_all(), eina_file_virtual_map_free(), eina_file_virtual_map_new(), eina_tmpstr_add_length(), eina_tmpstr_del(), eina_tmpstr_len(), eina_tmpstr_manage_new_length(), eio_memory_burst_limit_set(), elm_store_free(), emotion_shutdown(), evas_async_events_put(), and efl::eina::mutex::unlock().

◆ eina_lock_debug()

static void eina_lock_debug ( const Eina_Lock *  mutex)
inlinestatic

Print debug information about a lock.

Parameters
[in]mutexThe #Eina_Lock to print debug info for.

This function prints debug information for mutex. The information is platform dependant. On POSIX systems it prints the address of mutex, lock state, thread number and a backtrace.

Note
If EINA_HAVE_DEBUG_THREADS is not defined, this function does nothing.
This function is implemented on Win32 or WinCE, but it does not not produce any output, regardless of EINA_HAVE_DEBUG_THREADS being set.

Referenced by efl::eina::mutex::debug(), and eina_threads_shutdown().

◆ eina_condition_new()

static Eina_Bool eina_condition_new ( Eina_Condition *  cond,
Eina_Lock *  mutex 
)
inlinestatic

Initializes a new condition variable.

Parameters
[in]condThe condition variable to create
[in]mutexThe #Eina_Lock structure that controls access to this condition variable
Returns
EINA_TRUE on success, EINA_FALSE otherwise.

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.

See also
eina_condition_free()
Examples:
ecore_thread_example.c.

Referenced by efl::eina::condition_variable::condition_variable(), ecore_init(), ecore_main_loop_thread_safe_call_sync(), ecore_thread_main_loop_begin(), eio_init(), and efl::eina::thread::thread().

◆ eina_condition_free()

static void eina_condition_free ( Eina_Condition *  cond)
inlinestatic

Deallocates a condition variable.

Parameters
[in]condThe condition variable to be deallocated.

This function deallocates a condition variable and does any platform dependent cleanup that is required.

See also
eina_condition_new()
Examples:
ecore_thread_example.c.

Referenced by evas_async_events_put(), and efl::eina::condition_variable::~condition_variable().

◆ eina_condition_wait()

static Eina_Bool eina_condition_wait ( Eina_Condition *  cond)
inlinestatic

Causes a thread to wait until signaled by the condition.

Parameters
[in]condThe #Eina_Condition upon which the thread waits.
Returns
EINA_TRUE on success, EINA_FALSE otherwise.

This function makes a thread block until a signal is sent to it via cond.

See also
eina_condition_timedwait()
Examples:
ecore_thread_example.c.

Referenced by ecore_main_loop_thread_safe_call_sync(), ecore_thread_main_loop_begin(), ecore_thread_main_loop_end(), evas_async_events_put(), and efl::eina::condition_variable::wait().

◆ eina_condition_timedwait()

static Eina_Bool eina_condition_timedwait ( Eina_Condition *  cond,
double  t 
)
inlinestatic

Causes a thread to wait until signaled by the condition or a timeout is reached.

Parameters
[in]condThe #Eina_Condition upon which the thread waits.
[in]tThe maximum amount of time to wait, in seconds.
Returns
EINA_TRUE on success, EINA_FALSE otherwise.

This function makes a thread block until either a signal is sent to it via cond or t seconds have passed.

See also
eina_condition_wait()

◆ eina_condition_broadcast()

static Eina_Bool eina_condition_broadcast ( Eina_Condition *  cond)
inlinestatic

Signal all threads waiting for a condition.

Parameters
[in]condThe #Eina_Condition that signals all its waiting threads.
Returns
EINA_TRUE on success, EINA_FALSE otherwise.

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.

See also
eina_condition_signal()

Referenced by ecore_thread_main_loop_end(), eio_memory_burst_limit_set(), evas_async_events_put(), and efl::eina::condition_variable::notify_all().

◆ eina_condition_signal()

static Eina_Bool eina_condition_signal ( Eina_Condition *  cond)
inlinestatic

Signal a thread waiting for a condition.

Parameters
[in]condThe #Eina_Condition that signals its waiting thread.
Returns
EINA_TRUE on success, EINA_FALSE otherwise.

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.

Note
If there is more than one thread waiting on this condition, one of them is signalled, but which one is undefined.
See also
eina_condition_broadcast()
Examples:
ecore_thread_example.c.

Referenced by efl::eina::condition_variable::notify_one().

◆ eina_rwlock_new()

static Eina_Bool eina_rwlock_new ( Eina_RWLock *  mutex)
inlinestatic

Initializes a new #Eina_RWLock.

Parameters
[in]mutexThe #Eina_RWLock to be initialized.
Returns
EINA_TRUE on success, EINA_FALSE otherwise.

This function initializes an #Eina_RWLock with appropriate values. These values are platform dependent as is the structure of the #Eina_RWLock itself.

See also
eina_rwlock_free()

◆ eina_rwlock_free()

static void eina_rwlock_free ( Eina_RWLock *  mutex)
inlinestatic

Deallocates an #Eina_RWLock.

Parameters
[in]mutexThe #Eina_RWLock structure to be deallocated.

This function deallocates an #Eina_RWLock and does any platform dependent cleanup that is required.

See also
eina_rwlock_new()

◆ eina_rwlock_take_read()

static Eina_Lock_Result eina_rwlock_take_read ( Eina_RWLock *  mutex)
inlinestatic

Attempts to take a read lock.

Parameters
[in]mutexThe #Eina_RWLock to take.
Returns
Returns EINA_LOCK_SUCCEED on success, EINA_LOCK_FAIL on failure.

This function attempts to gain a read lock on the indicated #Eina_RWLock. If the #Eina_RWLock is write locked, this call can be blocked until the lock is released.

Note
This function never return EINA_LOCK_DEADLOCK.
See also
eina_rwlock_release()

◆ eina_rwlock_take_write()

static Eina_Lock_Result eina_rwlock_take_write ( Eina_RWLock *  mutex)
inlinestatic

Attempts to take a write lock.

Parameters
[in]mutexThe #Eina_RWLock to take.
Returns
Returns EINA_LOCK_SUCCEED on success, EINA_LOCK_FAIL on failure.

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 can be blocked until the lock is released.

Note
This function never return EINA_LOCK_DEADLOCK.
See also
eina_rwlock_release()

◆ eina_rwlock_release()

static Eina_Lock_Result eina_rwlock_release ( Eina_RWLock *  mutex)
inlinestatic

Releases a lock.

Parameters
[in]mutexThe #Eina_RWLock to release.
Returns
Returns EINA_LOCK_SUCCEED on success. If it fails, EINA_LOCK_FAIL is returned.

This function releases the lock on the indicated #Eina_RWLock.

See also
eina_rwlock_take_read()
eina_rwlock_take_write()

◆ eina_tls_new()

static Eina_Bool eina_tls_new ( Eina_TLS *  key)
inlinestatic

Initializes a new #Eina_TLS, or thread level storage, to store thread specific data.

Parameters
[in]keyThe #Eina_TLS to be initialized.
Returns
EINA_TRUE on success, EINA_FALSE otherwise.

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.

Note
use eina_tls_cb_new() instead to set a callback for deallocating key.
See also
eina_tls_cb_new()
eina_tls_free()

Referenced by evas_gl_new().

◆ eina_tls_cb_new()

static Eina_Bool eina_tls_cb_new ( Eina_TLS *  key,
Eina_TLS_Delete_Cb  delete_cb 
)
inlinestatic

Initializes a new #Eina_TLS, or thread level storage, to store thread specific data.

Parameters
[in]keyThe #Eina_TLS to be initialized.
[in]delete_cbA pointer to a function that deallocates key.
Returns
EINA_TRUE on success, EINA_FALSE otherwise.

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.

See also
eina_tls_new()
eina_tls_free()

◆ eina_tls_free()

static void eina_tls_free ( Eina_TLS  key)
inlinestatic

Frees an allocated #Eina_TLS.

Parameters
[in]keyThe #Eina_TLS to be freed.

This function frees the #Eina_TLS key. The implementation is platform dependent.

See also
eina_tls_new()
eina_tls_cb_new()

◆ eina_tls_get()

static void* eina_tls_get ( Eina_TLS  key)
inlinestatic

Gets the value in #Eina_TLS for this thread.

Parameters
[in]keyThe #Eina_TLS to be retrieved.
Returns
A pointer to the data associated with key.

This function gets a pointer to the data associated with #Eina_TLS key for this thread. The implementation is platform dependent.

See also
eina_tls_set()

Referenced by eina_error_get(), evas_gl_current_evas_gl_get(), and evas_gl_free().

◆ eina_tls_set()

static Eina_Bool eina_tls_set ( Eina_TLS  key,
const void *  data 
)
inlinestatic

Sets the value in Eina_TLS for this thread.

Parameters
[in]keyThe #Eina_TLS to be set.
[in]dataA pointer to the data to be stored.

This function sets the value associated with key to the pointer to the data data. The implementation is platform dependent.

Returns
EINA_TRUE on success, EINA_FALSE otherwise.
See also
eina_tls_get()

Referenced by eina_error_set(), evas_gl_free(), evas_gl_make_current(), and evas_gl_new().

◆ eina_semaphore_new()

static Eina_Bool eina_semaphore_new ( Eina_Semaphore *  sem,
int  count_init 
)
inlinestatic

Initializes a new #Eina_Semaphore.

Parameters
[in]semThe #Eina_Semaphore to be initialized.
[in]count_initIndicates the initial count of threads waiting on this semaphore.
Returns
EINA_TRUE on success, EINA_FALSE otherwise.

This function initializes an unnamed #Eina_Semaphore with appropriate values. These values are platform dependent.

Note
Semaphores are not avialable on the WinCE platform.
See also
eina_semaphore_free()

Referenced by eina_thread_queue_new().

◆ eina_semaphore_free()

static Eina_Bool eina_semaphore_free ( Eina_Semaphore *  sem)
inlinestatic

Frees an allocated #Eina_Semaphore.

Parameters
[in]semThe #Eina_Semaphore to be freed.
Returns
EINA_TRUE on success, EINA_FALSE otherwise.

This function frees the #Eina_Semaphore sem. The implementation is platform dependent.

See also
eina_semaphore_new()

Referenced by eina_thread_queue_free().

◆ eina_semaphore_lock()

static Eina_Bool eina_semaphore_lock ( Eina_Semaphore *  sem)
inlinestatic

Gets a lock on an #Eina_Semaphore.

Parameters
[in]semThe #Eina_Semaphore to lock.
Returns
EINA_TRUE on success, EINA_FALSE otherwise.

This function locks the #Eina_Semaphore sem. The implementation is platform dependent.

See also
eina_semaphore_release()

◆ eina_semaphore_release()

static Eina_Bool eina_semaphore_release ( Eina_Semaphore *  sem,
int  count_release 
)
inlinestatic

Releases a lock on an #Eina_Semaphore.

Parameters
[in]semThe #Eina_Semaphore to release.
[in]count_releaseNot used.
Returns
EINA_TRUE on success, EINA_FALSE otherwise.

This function releases a lock on the #Eina_Semaphore sem. The implementation is platform dependent.

See also
eina_semaphore_lock()

◆ eina_barrier_new()

static Eina_Bool eina_barrier_new ( Eina_Barrier *  barrier,
int  needed 
)
inlinestatic

Initializes a new #Eina_Barrier.

Parameters
[in]barrierThe #Eina_Barrier to be initialized.
[in]neededThe number of thread waits that causes this barrier to be reset.
Returns
EINA_TRUE on success, EINA_FALSE otherwise.

This function initializes a new #Eina_Barrier. It sets the needed flag to the value of needed, sets the barrier's count member to 0 and creates new #Eina_Lock and #Eina_Condition objects for the barrier.

See also
eina_barrier_free()

◆ eina_barrier_free()

static void eina_barrier_free ( Eina_Barrier *  barrier)
inlinestatic

Frees an allocated #Eina_Barrier.

Parameters
[in]barrierThe #Eina_Barrier to be freed.

This function frees the #Eina_Barrier barrier.

See also
eina_barrier_new()

◆ eina_barrier_wait()

static Eina_Bool eina_barrier_wait ( Eina_Barrier *  barrier)
inlinestatic

Increments the count of threads that are waiting on barrier.

Parameters
[in]barrierThe #Eina_Barrier to be incremented.
Returns
EINA_TRUE on success, else EINA_FALSE otherwise.

When the count of threads reaches the needed value for the barrier, all waiting threads are notified via eina_condition_broadcast().

◆ eina_spinlock_new()

static Eina_Bool eina_spinlock_new ( Eina_Spinlock *  spinlock)
inlinestatic

Initializes a new #Eina_Spinlock.

Parameters
[in]spinlockThe #Eina_Spinlock to be initialized.
Returns
EINA_TRUE on success, EINA_FALSE otherwise.

This function initializes a new #Eina_Spinlock, if spinlocks are available. If spinlocks are not avialable, it creates a new #Eina_Lock.

Note
Spinlocks are only implemented on the POSIX platform and are only available if #EINA_HAVE_POSIX_SPINLOCK is defined. you get a new #Eina_Lock on All other platforms.
See also
eina_spinlock_free()

Referenced by eina_safepointer_unregister(), eina_thread_queue_new(), eio_init(), and eo_init().

◆ eina_spinlock_take()

static Eina_Lock_Result eina_spinlock_take ( Eina_Spinlock *  spinlock)
inlinestatic

Attempts to take a spinlock.

Parameters
[in]spinlockThe #Eina_Spinlock to take.
Returns
Returns EINA_LOCK_SUCCEED on success. If the operation fails because a deadlock condition exists, it returns EINA_LOCK_DEADLOCK. If some other condition causes the take to fail, EINA_LOCK_FAIL is returned.

This function attempts to gain a lock on the indicated #Eina_Spinlock. If the underlying #Eina_Spinlock is locked already, this call can be blocked 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.

See also
eina_spinlock_take_try()
eina_spinlock_release()

Referenced by eet_dictionary_count(), eet_dictionary_string_check(), eina_rectangle_new(), eina_safepointer_register(), eina_safepointer_unregister(), eina_stringshare_add_length(), eina_stringshare_del(), eina_stringshare_ref(), eina_thread_queue_poll(), eina_thread_queue_send(), eina_thread_queue_wait(), evas_async_events_fd_get(), evas_async_events_put(), and evas_render_updates_free().

◆ eina_spinlock_take_try()

static Eina_Lock_Result eina_spinlock_take_try ( Eina_Spinlock *  spinlock)
inlinestatic

Attempts to take a spinlock if possible.

Parameters
[in]spinlockThe #Eina_Spinlock to take.
Returns
Returns EINA_LOCK_SUCCEED on success. If the operation fails because a deadlock condition exists, it returns EINA_LOCK_DEADLOCK. If some other condition causes the take to fail, EINA_LOCK_FAIL is returned.

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.

See also
eina_spinlock_take_try()
eina_spinlock_release()

◆ eina_spinlock_release()

static Eina_Lock_Result eina_spinlock_release ( Eina_Spinlock *  spinlock)
inlinestatic

Releases a spinlock.

Parameters
[in]spinlockThe #Eina_Spinlock to release.
Returns
Returns EINA_LOCK_SUCCEED on success, EINA_LOCK_FAIL otherwise.

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).

See also
eina_spinlock_take()
eina_spinlock_take_try()

Referenced by eet_dictionary_count(), eet_dictionary_string_check(), eina_rectangle_new(), eina_safepointer_register(), eina_safepointer_unregister(), eina_stringshare_add_length(), eina_stringshare_del(), eina_stringshare_ref(), eina_thread_queue_poll(), eina_thread_queue_send(), eina_thread_queue_wait(), evas_async_events_fd_get(), evas_async_events_put(), and evas_render_updates_free().

◆ eina_spinlock_free()

static void eina_spinlock_free ( Eina_Spinlock *  spinlock)
inlinestatic

Deallocates an #Eina_Spinlock.

Parameters
[in]spinlockThe #Eina_Spinlock to be deallocated.

This function deallocates an #Eina_Spinlock and does any platform dependent cleanup that is required.

Referenced by eina_safepointer_unregister(), eina_thread_queue_free(), eo_class_name_get(), and evas_free().