Method

GLibRWLockinit

since: 2.32

Declaration

void
g_rw_lock_init (
  GRWLock* rw_lock
)

Description

Initializes a GRWLock so that it can be used.

This function is useful to initialize a lock that has been allocated on the stack, or as part of a larger structure. It is not necessary to initialise a reader-writer lock that has been statically allocated.

  typedef struct {
    GRWLock l;
    ...
  } Blob;

Blob *b;

b = g_new (Blob, 1);
g_rw_lock_init (&b->l);

To undo the effect of g_rw_lock_init() when a lock is no longer needed, use g_rw_lock_clear().

Calling g_rw_lock_init() on an already initialized GRWLock leads to undefined behaviour.

Available since: 2.32