// Workaround for a bug in macOSX kernel's pthread support (fixed in Mojave?). // Avoid ever allocating a pthread_mutex_t at the same address as one of our // former pthread_cond_t, by using freelists of mutexes and condvars. // Conditional to avoid extra indirection and padding loss on other platforms. #ifdef __APPLE__ #define PLATFORM_MONITOR_IMPL_INDIRECT 1 #else #define PLATFORM_MONITOR_IMPL_INDIRECT 0 #endif
// Platform specific implementations that underpin VM Mutex/Monitor classes. // Note that we use "normal" pthread_mutex_t attributes so that recursive // locking is not supported, which matches the expected semantics of the // VM Mutex class.
class PlatformMutex : public CHeapObj<mtSynchronizer> { #if PLATFORM_MONITOR_IMPL_INDIRECT class Mutex : public CHeapObj<mtSynchronizer> { public:
pthread_mutex_t _mutex;
Mutex* _next;
Mutex();
~Mutex();
};
Mutex* _impl;
static pthread_mutex_t _freelist_lock; // used for mutex and cond freelists static Mutex* _mutex_freelist;
protected: class WithFreeListLocked;
pthread_mutex_t* mutex() { return &(_impl->_mutex); }
public:
PlatformMutex(); // Use freelist allocation of impl.
~PlatformMutex();
class PlatformMonitor : public PlatformMutex { #if PLATFORM_MONITOR_IMPL_INDIRECT class Cond : public CHeapObj<mtSynchronizer> { public:
pthread_cond_t _cond;
Cond* _next;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.