diff options
author | Leith Bade <leith@leithalweapon.geek.nz> | 2014-11-09 22:36:37 +1100 |
---|---|---|
committer | Leith Bade <leith@leithalweapon.geek.nz> | 2014-11-09 22:36:37 +1100 |
commit | 28d66bb6f856b3836616f9574c38dbb9fe749d92 (patch) | |
tree | e668fa8f0a75c83ad47e659ec8bc731e965c2169 /include/mbgl/util | |
parent | b3e3c21129671884e130d34507057676484656b4 (diff) | |
download | qtlocation-mapboxgl-28d66bb6f856b3836616f9574c38dbb9fe749d92.tar.gz |
Add Map::pause/resume
Fixed bug after switching apps
Diffstat (limited to 'include/mbgl/util')
-rw-r--r-- | include/mbgl/util/uv.hpp | 2 | ||||
-rw-r--r-- | include/mbgl/util/uv_detail.hpp | 18 |
2 files changed, 20 insertions, 0 deletions
diff --git a/include/mbgl/util/uv.hpp b/include/mbgl/util/uv.hpp index 3c533cfbf8..0e828bb4f3 100644 --- a/include/mbgl/util/uv.hpp +++ b/include/mbgl/util/uv.hpp @@ -21,6 +21,8 @@ class thread; class rwlock; class loop; class worker; +class mutex; +class cond; } diff --git a/include/mbgl/util/uv_detail.hpp b/include/mbgl/util/uv_detail.hpp index 3bbfa4ac5a..112339c1b5 100644 --- a/include/mbgl/util/uv_detail.hpp +++ b/include/mbgl/util/uv_detail.hpp @@ -52,6 +52,7 @@ private: }; class mutex { + friend class cond; public: inline mutex() { if (uv_mutex_init(&mtx) != 0) { @@ -66,6 +67,23 @@ private: uv_mutex_t mtx; }; +class cond { +public: + inline cond() { + if (uv_cond_init(&cnd) != 0) { + throw std::runtime_error("failed to initialize condition variable"); + } + } + inline ~cond() { uv_cond_destroy(&cnd); } + inline void signal() { uv_cond_signal(&cnd); } + inline void broadcast() { uv_cond_broadcast(&cnd); } + inline void wait(mutex &mtx) { uv_cond_wait(&cnd, &mtx.mtx); } + inline void timedwait(mutex &mtx, uint64_t timeout) { uv_cond_timedwait(&cnd, &mtx.mtx, timeout); } + +private: + uv_cond_t cnd; +}; + class lock { public: lock(mutex &mtx_) : mtx(mtx_) { mtx.lock(); } |