Function Macro

GLibLOCK_DEFINE

Declaration [src]

#define G_LOCK_DEFINE (
  name
)

Description [src]

The G_LOCK_ macros provide a convenient interface to GMutex. G_LOCK_DEFINE defines a lock. It can appear in any place where variable definitions may appear in programs, i.e. in the first block of a function or outside of functions. The name parameter will be mangled to get the name of the GMutex. This means that you can use names of existing variables as the parameter - e.g. the name of the variable you intend to protect with the lock. Look at our give_me_next_number() example using the G_LOCK macros:

Here is an example for using the G_LOCK convenience macros:

  G_LOCK_DEFINE (current_number);

  int
  give_me_next_number (void)
  {
    static int current_number = 0;
    int ret_val;

    G_LOCK (current_number);
    ret_val = current_number = calc_next_number (current_number);
    G_UNLOCK (current_number);

    return ret_val;
  }

This function is not directly available to language bindings.

Parameters

name

Type: -

The name of the lock.