Function: make-mutex

make-mutex is a function defined in thread.c.

Signature

(make-mutex &optional NAME)

Documentation

Create a mutex.

A mutex provides a synchronization point for threads. Only one thread at a time can hold a mutex. Other threads attempting to acquire it will block until the mutex is available.

A thread can acquire a mutex any number of times.

NAME, if given, is used as the name of the mutex. The name is informational only.

View in manual

Probably introduced at or before Emacs version 26.1.

Source Code

// Defined in /usr/src/emacs/src/thread.c
{
  if (!NILP (name))
    CHECK_STRING (name);

  struct Lisp_Mutex *mutex
    = ALLOCATE_ZEROED_PSEUDOVECTOR (struct Lisp_Mutex, name, PVEC_MUTEX);
  mutex->name = name;
  lisp_mutex_init (&mutex->mutex);

  Lisp_Object result;
  XSETMUTEX (result, mutex);
  return result;
}