diff options
author | Konstantin Käfer <mail@kkaefer.com> | 2014-05-14 13:41:55 +0200 |
---|---|---|
committer | Konstantin Käfer <mail@kkaefer.com> | 2014-05-14 13:41:55 +0200 |
commit | ac9a678ce53f922fb1d6b8c6fec3bc5d912cdb5f (patch) | |
tree | 4aff5886057e5b2d01564831bca86d3379814767 /include/llmr/util | |
parent | 164aef8b26de0ab371b03e806150c1f426e30c42 (diff) | |
download | qtlocation-mapboxgl-ac9a678ce53f922fb1d6b8c6fec3bc5d912cdb5f.tar.gz |
fix lock initialization
background: for non-debug builds, assert() gets compiled away, so the locks are not initialized
Diffstat (limited to 'include/llmr/util')
-rw-r--r-- | include/llmr/util/uv.hpp | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/include/llmr/util/uv.hpp b/include/llmr/util/uv.hpp index f0b0fe3925..aae5a1b05f 100644 --- a/include/llmr/util/uv.hpp +++ b/include/llmr/util/uv.hpp @@ -15,7 +15,11 @@ namespace uv { class mutex { public: - inline mutex() { assert(uv_mutex_init(&mtx) == 0); } + inline mutex() { + if (uv_mutex_init(&mtx) != 0) { + throw std::runtime_error("failed to initialize mutex"); + } + } inline ~mutex() { uv_mutex_destroy(&mtx); } inline void lock() { uv_mutex_lock(&mtx); } inline void unlock() { uv_mutex_unlock(&mtx); } @@ -35,7 +39,11 @@ private: class rwlock { public: - inline rwlock() { assert(uv_rwlock_init(&mtx) == 0); } + inline rwlock() { + if (uv_rwlock_init(&mtx) != 0) { + throw std::runtime_error("failed to initialize read-write lock"); + } + } inline ~rwlock() { uv_rwlock_destroy(&mtx); } inline void rdlock() { uv_rwlock_rdlock(&mtx); } inline void wrlock() { uv_rwlock_wrlock(&mtx); } |