Mstdlib-1.24.0

Typedefs

typedef struct M_thread_rwlock M_thread_rwlock_t
 

Enumerations

enum  M_thread_rwlock_type_t {
  M_THREAD_RWLOCK_TYPE_READ = 0 ,
  M_THREAD_RWLOCK_TYPE_WRITE
}
 

Functions

M_thread_rwlock_tM_thread_rwlock_create (void)
 
void M_thread_rwlock_destroy (M_thread_rwlock_t *rwlock)
 
M_bool M_thread_rwlock_lock (M_thread_rwlock_t *rwlock, M_thread_rwlock_type_t type)
 
M_bool M_thread_rwlock_unlock (M_thread_rwlock_t *rwlock)
 

Detailed Description

Read/Write locks

Typedef Documentation

◆ M_thread_rwlock_t

typedef struct M_thread_rwlock M_thread_rwlock_t

Enumeration Type Documentation

◆ M_thread_rwlock_type_t

Read/Write lock, lock type.

Enumerator
M_THREAD_RWLOCK_TYPE_READ 

Lock for read.

M_THREAD_RWLOCK_TYPE_WRITE 

Lock for write.

Function Documentation

◆ M_thread_rwlock_create()

M_thread_rwlock_t * M_thread_rwlock_create ( void  )

Read/Write lock create.

Read/Write locks allow multiple readers to be hold the lock at the same time. A write lock will be allowed once all readers have released their locks.

For new locks waiting writers are preferred. Meaning a if a writer is waiting new read locks will not be given until all waiting writers has received and released their locks.

Returns
Read/Write lock on success otherwise NULL on error.

◆ M_thread_rwlock_destroy()

void M_thread_rwlock_destroy ( M_thread_rwlock_t rwlock)

Destroy a read/write lock.

Parameters
[in]rwlockThe lock.

◆ M_thread_rwlock_lock()

M_bool M_thread_rwlock_lock ( M_thread_rwlock_t rwlock,
M_thread_rwlock_type_t  type 
)

Lock a read/write lock.

The thread will block waiting to acquire the lock.

Parameters
[in]rwlockThe lock.
[in]typeThe type of lock to acquire.
Returns
M_TRUE If the lock was acquired. Otherwise M_FALSE.

◆ M_thread_rwlock_unlock()

M_bool M_thread_rwlock_unlock ( M_thread_rwlock_t rwlock)

Unlock a read/write lock.

Parameters
[in]rwlockThe lock.
Returns
M_TRUE If on success. Otherwise M_FALSE.