Method

GLibRecMutexinit

Declaration

void
g_rec_mutex_init (
  GRecMutex* rec_mutex
)

Description

Initializes a GRecMutex so that it can be used.

This function is useful to initialize a recursive mutex that has been allocated on the stack, or as part of a larger structure.

It is not necessary to initialise a recursive mutex that has been statically allocated.

  typedef struct {
    GRecMutex m;
    ...
  } Blob;

Blob *b;

b = g_new (Blob, 1);
g_rec_mutex_init (&b->m);

Calling g_rec_mutex_init() on an already initialized GRecMutex leads to undefined behaviour.

To undo the effect of g_rec_mutex_init() when a recursive mutex is no longer needed, use g_rec_mutex_clear().

Available since:2.32