inline MutexImplPosix() { if (RECURSIVE) { DO_AND_DEBUG_ASSERT_ZERO(pthread_mutex_init(&internal_mutex_, threading_posix_internal::kMutexattrRecursive)); } else { DO_AND_DEBUG_ASSERT_ZERO(pthread_mutex_init(&internal_mutex_, threading_posix_internal::kMutexattrNormal)); } }
explicit MutexAttrWrapper(bool recursive) { DO_AND_DEBUG_ASSERT_ZERO(pthread_mutexattr_init(&internal_mutex_attr_)); if (recursive) { DO_AND_DEBUG_ASSERT_ZERO(pthread_mutexattr_settype(&internal_mutex_attr_, PTHREAD_MUTEX_RECURSIVE)); } else { DO_AND_DEBUG_ASSERT_ZERO(pthread_mutexattr_settype(&internal_mutex_attr_, PTHREAD_MUTEX_NORMAL)); } }
void StorageManager::deallocateSlots(void *slots, const std::size_t num_slots) { #if defined(QUICKSTEP_HAVE_MMAP_LINUX_HUGETLB) \ || defined(QUICKSTEP_HAVE_MMAP_BSD_SUPERPAGE) \ || defined(QUICKSTEP_HAVE_MMAP_PLAIN) DO_AND_DEBUG_ASSERT_ZERO(munmap(slots, num_slots * kSlotSizeBytes)); #else free(slots); #endif total_memory_usage_ -= num_slots; }
inline void unlock() { DO_AND_DEBUG_ASSERT_ZERO(pthread_mutex_unlock(&internal_mutex_)); }
inline ~MutexImplPosix() { DO_AND_DEBUG_ASSERT_ZERO(pthread_mutex_destroy(&internal_mutex_)); }
inline void signalAll() { DO_AND_DEBUG_ASSERT_ZERO(pthread_cond_broadcast(&internal_condition_var_)); }
explicit ConditionVariableImplPosix(pthread_mutex_t *parent_mutex) : parent_mutex_(parent_mutex) { DO_AND_DEBUG_ASSERT_ZERO(pthread_cond_init(&internal_condition_var_, nullptr)); }
inline void await() { DO_AND_DEBUG_ASSERT_ZERO(pthread_cond_wait(&internal_condition_var_, parent_mutex_)); }
inline void signalOne() { DO_AND_DEBUG_ASSERT_ZERO(pthread_cond_signal(&internal_condition_var_)); }
~ConditionVariableImplPosix() { DO_AND_DEBUG_ASSERT_ZERO(pthread_cond_destroy(&internal_condition_var_)); }
inline void unlockShared() { DO_AND_DEBUG_ASSERT_ZERO(pthread_rwlock_unlock(&internal_rwlock_)); }
inline void lock() { DO_AND_DEBUG_ASSERT_ZERO(pthread_rwlock_wrlock(&internal_rwlock_)); }
inline ~SharedMutexImplPosix() { DO_AND_DEBUG_ASSERT_ZERO(pthread_rwlock_destroy(&internal_rwlock_)); }
inline SharedMutexImplPosix() { DO_AND_DEBUG_ASSERT_ZERO(pthread_rwlock_init(&internal_rwlock_, nullptr)); }