diff --git a/include/mutex.hpp b/include/mutex.hpp index 3d37a761..d924c9f9 100644 --- a/include/mutex.hpp +++ b/include/mutex.hpp @@ -17,29 +17,29 @@ struct SharedMutex { pthread_rwlock_t rwlock; SharedMutex() { - if (pthread_rwlock_init(&rwlock, NULL)) - throw Exception("pthread_rwlock_init failed"); + int err = pthread_rwlock_init(&rwlock, NULL); + assert(!err); } ~SharedMutex() { pthread_rwlock_destroy(&rwlock); } void lock() { - if (pthread_rwlock_wrlock(&rwlock)) - throw Exception("pthread_rwlock_wrlock failed"); + int err = pthread_rwlock_wrlock(&rwlock); + assert(!err); } /** Returns whether the lock was acquired. */ bool try_lock() { return pthread_rwlock_trywrlock(&rwlock) == 0; } void unlock() { - if (pthread_rwlock_unlock(&rwlock)) - throw Exception("pthread_rwlock_unlock failed"); + int err = pthread_rwlock_unlock(&rwlock); + assert(!err); } void lock_shared() { - if (pthread_rwlock_rdlock(&rwlock)) - throw Exception("pthread_rwlock_rdlock failed"); + int err = pthread_rwlock_rdlock(&rwlock); + assert(!err); } /** Returns whether the lock was acquired. */ bool try_lock_shared() {