summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorKonstantin Käfer <mail@kkaefer.com>2015-02-11 13:25:23 -0800
committerKonstantin Käfer <mail@kkaefer.com>2015-03-06 15:42:33 +0100
commitcf235c65926d72d00d2eb1a6ace9f9ab2d701a5c (patch)
treea3c861ee46a49b8ecafdb0450c2f6cc9289a1b19 /include
parent86455585ee9a2be5aed210411605e712eafd98d7 (diff)
downloadqtlocation-mapboxgl-cf235c65926d72d00d2eb1a6ace9f9ab2d701a5c.tar.gz
move readlock/writelock to uv.hpp and add movable lock/mutex
Diffstat (limited to 'include')
-rw-r--r--include/mbgl/util/uv.hpp41
1 files changed, 41 insertions, 0 deletions
diff --git a/include/mbgl/util/uv.hpp b/include/mbgl/util/uv.hpp
index 85f93e78bd..169bee1912 100644
--- a/include/mbgl/util/uv.hpp
+++ b/include/mbgl/util/uv.hpp
@@ -2,6 +2,7 @@
#define MBGL_UTIL_UV
#include <string>
+#include <memory>
typedef struct uv_handle_s uv_handle_t;
typedef struct uv_async_s uv_async_t;
@@ -20,6 +21,46 @@ class worker;
class mutex;
class cond;
+class lock {
+public:
+ lock(mutex &);
+ lock(const std::unique_ptr<mutex> &);
+ lock(const lock &) = delete;
+ lock(lock &&lock);
+ lock &operator=(const lock &lock) = delete;
+ lock &operator=(lock &&lock);
+ ~lock();
+private:
+ mutex *mtx = nullptr;
+};
+
+class readlock {
+public:
+ readlock(rwlock &);
+ readlock(const std::unique_ptr<rwlock> &);
+ readlock(const readlock &) = delete;
+ readlock(readlock &&lock);
+ readlock &operator=(const readlock &lock) = delete;
+ readlock &operator=(readlock &&lock);
+ ~readlock();
+private:
+ rwlock *mtx = nullptr;
+};
+
+class writelock {
+public:
+ writelock(rwlock &);
+ writelock(const std::unique_ptr<rwlock> &);
+ writelock(const writelock &) = delete;
+ writelock(writelock &&lock);
+ writelock &operator=(const writelock &lock) = delete;
+ writelock &operator=(writelock &&lock);
+ ~writelock();
+private:
+ rwlock *mtx = nullptr;
+};
+
+
const char *getFileRequestError(uv_fs_t *req);
template <typename T>