Mutex

Mutual exclusion primitive for thread synchronization

It

Platform-specific mutex handle

#if defined(_WIN32) || defined(_WIN64)
struct It {
  CRITICAL_SECTION handle
}
#else
struct It {
  pthread_mutex_t handle
}
#endif

create

Create and initialize a new mutex

Mutex.It create()

Returns — Initialized mutex object


destroy

Destroy a mutex and release its resources

U0 destroy(Mutex mutex)

Parameters

  • mutex — The mutex to destroy

lock

Acquire a mutex, blocking until it is available

U0 lock(Mutex mutex)

Parameters

  • mutex — The mutex to lock

unlock

Release a previously acquired mutex

U0 unlock(Mutex mutex)

Parameters

  • mutex — The mutex to unlock