Method

GLibRWLockreader_lock

since: 2.32

Declaration

void
g_rw_lock_reader_lock (
  GRWLock* rw_lock
)

Description

Obtain a read lock on rw_lock. If another thread currently holds the write lock on rw_lock, the current thread will block until the write lock was (held and) released. If another thread does not hold the write lock, but is waiting for it, it is implementation defined whether the reader or writer will block. Read locks can be taken recursively.

Calling g_rw_lock_reader_lock() while the current thread already owns a write lock leads to undefined behaviour. Read locks however can be taken recursively, in which case you need to make sure to call g_rw_lock_reader_unlock() the same amount of times.

It is implementation-defined how many read locks are allowed to be held on the same lock simultaneously. If the limit is hit, or if a deadlock is detected, a critical warning will be emitted.

Available since: 2.32