|
@@ -18,6 +18,7 @@ struct SharedMutex { |
|
|
|
|
|
|
|
|
SharedMutex() { |
|
|
SharedMutex() { |
|
|
int err = pthread_rwlock_init(&rwlock, NULL); |
|
|
int err = pthread_rwlock_init(&rwlock, NULL); |
|
|
|
|
|
(void) err; |
|
|
assert(!err); |
|
|
assert(!err); |
|
|
} |
|
|
} |
|
|
~SharedMutex() { |
|
|
~SharedMutex() { |
|
@@ -26,6 +27,7 @@ struct SharedMutex { |
|
|
|
|
|
|
|
|
void lock() { |
|
|
void lock() { |
|
|
int err = pthread_rwlock_wrlock(&rwlock); |
|
|
int err = pthread_rwlock_wrlock(&rwlock); |
|
|
|
|
|
(void) err; |
|
|
assert(!err); |
|
|
assert(!err); |
|
|
} |
|
|
} |
|
|
/** Returns whether the lock was acquired. */ |
|
|
/** Returns whether the lock was acquired. */ |
|
@@ -34,11 +36,13 @@ struct SharedMutex { |
|
|
} |
|
|
} |
|
|
void unlock() { |
|
|
void unlock() { |
|
|
int err = pthread_rwlock_unlock(&rwlock); |
|
|
int err = pthread_rwlock_unlock(&rwlock); |
|
|
|
|
|
(void) err; |
|
|
assert(!err); |
|
|
assert(!err); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void lock_shared() { |
|
|
void lock_shared() { |
|
|
int err = pthread_rwlock_rdlock(&rwlock); |
|
|
int err = pthread_rwlock_rdlock(&rwlock); |
|
|
|
|
|
(void) err; |
|
|
assert(!err); |
|
|
assert(!err); |
|
|
} |
|
|
} |
|
|
/** Returns whether the lock was acquired. */ |
|
|
/** Returns whether the lock was acquired. */ |
|
|