1 #ifndef D_MUTEX_H_INCLUDED
2 #define D_MUTEX_H_INCLUDED
9 // Simple non-recursive mutex, with priority inheritance to avoid priority inversion.
14 pthread_mutex_t mutex;
19 // Avoid priority inversion by using PTHREAD_PRIO_INHERIT
20 pthread_mutexattr_t attribs;
21 pthread_mutexattr_init(&attribs);
22 pthread_mutexattr_setprotocol(&attribs, PTHREAD_PRIO_INHERIT);
23 pthread_mutex_init(&mutex, &attribs);
28 pthread_mutex_lock(&mutex);
33 pthread_mutex_unlock(&mutex);
38 using DMutex = std::mutex;
40 // A "null" mutex, for which locking / unlocking actually does nothing.