summaryrefslogtreecommitdiff
path: root/include/mbgl
diff options
context:
space:
mode:
authorLeith Bade <leith@mapbox.com>2014-12-04 22:19:46 +1100
committerLeith Bade <leith@mapbox.com>2014-12-04 22:19:46 +1100
commit8f1754cf0a7054dd1f6b16260eb99a2afd739f43 (patch)
tree9010e5835e263571b6b6732add21b51063cb0f81 /include/mbgl
parentc817e476f3e2f424139dea968cb9747354bce1bc (diff)
parent57249ca32c7b0684be36f5195d4967e6517fe75b (diff)
downloadqtlocation-mapboxgl-8f1754cf0a7054dd1f6b16260eb99a2afd739f43.tar.gz
Merge branch 'master' of github.com:mapbox/mapbox-gl-native into android-mason
Conflicts: include/mbgl/storage/base_request.hpp include/mbgl/storage/file_request_baton.hpp include/mbgl/storage/http_request.hpp include/mbgl/storage/http_request_baton.hpp include/mbgl/util/uv_detail.hpp platform/darwin/http_request_baton_cocoa.mm platform/default/caching_http_file_source.cpp platform/default/http_request_baton_curl.cpp src/map/map.cpp src/storage/base_request.cpp src/storage/file_request.cpp src/storage/file_request_baton.cpp src/storage/http_request.cpp src/storage/http_request_baton.cpp
Diffstat (limited to 'include/mbgl')
-rw-r--r--include/mbgl/map/map.hpp8
-rw-r--r--include/mbgl/platform/default/caching_http_file_source.hpp4
-rw-r--r--include/mbgl/storage/base_request.hpp4
-rw-r--r--include/mbgl/storage/file_request_baton.hpp3
-rw-r--r--include/mbgl/storage/http_request.hpp3
-rw-r--r--include/mbgl/storage/http_request_baton.hpp3
-rw-r--r--include/mbgl/storage/request.hpp3
-rw-r--r--include/mbgl/storage/sqlite_store.hpp3
-rw-r--r--include/mbgl/util/uv.hpp1
-rw-r--r--include/mbgl/util/uv_detail.hpp67
10 files changed, 19 insertions, 80 deletions
diff --git a/include/mbgl/map/map.hpp b/include/mbgl/map/map.hpp
index f222036bfa..91205f03c6 100644
--- a/include/mbgl/map/map.hpp
+++ b/include/mbgl/map/map.hpp
@@ -9,8 +9,10 @@
#include <mbgl/util/time.hpp>
#include <mbgl/util/uv.hpp>
#include <mbgl/util/ptr.hpp>
+
#include <cstdint>
#include <atomic>
+#include <thread>
#include <iosfwd>
#include <set>
#include <vector>
@@ -159,7 +161,7 @@ private:
bool async = false;
std::unique_ptr<uv::loop> loop;
std::unique_ptr<uv::worker> workers;
- std::unique_ptr<uv::thread> thread;
+ std::thread thread;
std::unique_ptr<uv::async> asyncTerminate;
std::unique_ptr<uv::async> asyncRender;
std::unique_ptr<uv::async> asyncCleanup;
@@ -190,8 +192,8 @@ private:
View &view;
#ifndef NDEBUG
- const unsigned long mainThread;
- unsigned long mapThread = -1;
+ const std::thread::id mainThread;
+ std::thread::id mapThread;
#endif
Transform transform;
diff --git a/include/mbgl/platform/default/caching_http_file_source.hpp b/include/mbgl/platform/default/caching_http_file_source.hpp
index 058bdc7c3e..c394474881 100644
--- a/include/mbgl/platform/default/caching_http_file_source.hpp
+++ b/include/mbgl/platform/default/caching_http_file_source.hpp
@@ -3,6 +3,7 @@
#include <mbgl/storage/file_source.hpp>
+#include <thread>
#include <unordered_map>
typedef struct uv_messenger_s uv_messenger_t;
@@ -14,7 +15,6 @@ class SQLiteStore;
class CachingHTTPFileSource : public FileSource {
public:
- CachingHTTPFileSource(uv_loop_t*, const std::string &path_);
CachingHTTPFileSource(const std::string &path_);
~CachingHTTPFileSource();
@@ -33,7 +33,7 @@ public:
void retryAllPending();
private:
- unsigned long thread_id;
+ std::thread::id thread_id;
// Path to the cache database.
std::string path;
diff --git a/include/mbgl/storage/base_request.hpp b/include/mbgl/storage/base_request.hpp
index 82372416dc..5119c343e9 100644
--- a/include/mbgl/storage/base_request.hpp
+++ b/include/mbgl/storage/base_request.hpp
@@ -7,7 +7,7 @@
#include <string>
#include <forward_list>
#include <functional>
-
+#include <thread>
typedef struct uv_loop_s uv_loop_t;
typedef struct uv_async_s uv_async_t;
@@ -46,7 +46,7 @@ public:
virtual void retryImmediately();
public:
- const unsigned long threadId;
+ const std::thread::id threadId;
const std::string path;
std::unique_ptr<Response> response;
diff --git a/include/mbgl/storage/file_request_baton.hpp b/include/mbgl/storage/file_request_baton.hpp
index 1283038dd5..0c3fa16da3 100644
--- a/include/mbgl/storage/file_request_baton.hpp
+++ b/include/mbgl/storage/file_request_baton.hpp
@@ -2,6 +2,7 @@
#define MBGL_STORAGE_FILE_REQUEST_BATON
#include <mbgl/storage/file_request.hpp>
+#include <thread>
#include <uv.h>
@@ -19,7 +20,7 @@ struct FileRequestBaton {
static void notify_error(uv_fs_t *req);
static void cleanup(uv_fs_t *req);
- const unsigned long threadId;
+ const std::thread::id threadId;
FileRequest *request = nullptr;
uv_fs_t req;
uv_file fd = -1;
diff --git a/include/mbgl/storage/http_request.hpp b/include/mbgl/storage/http_request.hpp
index 261986793e..7f6da4fcc2 100644
--- a/include/mbgl/storage/http_request.hpp
+++ b/include/mbgl/storage/http_request.hpp
@@ -8,6 +8,7 @@
#include <string>
#include <memory>
#include <cassert>
+#include <thread>
typedef struct uv_loop_s uv_loop_t;
typedef struct uv_timer_s uv_timer_t;
@@ -40,7 +41,7 @@ private:
void removeBackoffTimer();
private:
- const unsigned long threadId;
+ const std::thread::id threadId;
uv_loop_t *const loop;
CacheRequestBaton *cache_baton = nullptr;
util::ptr<HTTPRequestBaton> httpBaton;
diff --git a/include/mbgl/storage/http_request_baton.hpp b/include/mbgl/storage/http_request_baton.hpp
index c7c80466ba..11abfb71d4 100644
--- a/include/mbgl/storage/http_request_baton.hpp
+++ b/include/mbgl/storage/http_request_baton.hpp
@@ -5,6 +5,7 @@
#include <mbgl/util/ptr.hpp>
#include <string>
+#include <thread>
typedef struct uv_async_s uv_async_t;
@@ -47,7 +48,7 @@ struct HTTPRequestBaton {
HTTPRequestBaton(const std::string &path);
~HTTPRequestBaton();
- const unsigned long threadId;
+ const std::thread::id threadId;
const std::string path;
HTTPRequest *request = nullptr;
diff --git a/include/mbgl/storage/request.hpp b/include/mbgl/storage/request.hpp
index e603ee527a..11b5541d18 100644
--- a/include/mbgl/storage/request.hpp
+++ b/include/mbgl/storage/request.hpp
@@ -5,6 +5,7 @@
#include <mbgl/storage/response.hpp>
#include <mbgl/util/ptr.hpp>
+#include <thread>
#include <forward_list>
typedef struct uv_loop_s uv_loop_t;
@@ -29,7 +30,7 @@ public:
void cancel();
private:
- const unsigned long thread_id;
+ const std::thread::id thread_id;
util::ptr<BaseRequest> base;
std::forward_list<Callback *> callbacks;
};
diff --git a/include/mbgl/storage/sqlite_store.hpp b/include/mbgl/storage/sqlite_store.hpp
index cb7730d0bf..a691b474e0 100644
--- a/include/mbgl/storage/sqlite_store.hpp
+++ b/include/mbgl/storage/sqlite_store.hpp
@@ -7,6 +7,7 @@
#include <uv.h>
#include <string>
+#include <thread>
typedef struct uv_worker_s uv_worker_t;
@@ -37,7 +38,7 @@ private:
static void deliverResult(uv_work_t *req, int status);
private:
- const unsigned long thread_id;
+ const std::thread::id thread_id;
util::ptr<mapbox::sqlite::Database> db;
uv_worker_t *worker = nullptr;
};
diff --git a/include/mbgl/util/uv.hpp b/include/mbgl/util/uv.hpp
index 73391062e5..f59037c1d8 100644
--- a/include/mbgl/util/uv.hpp
+++ b/include/mbgl/util/uv.hpp
@@ -12,7 +12,6 @@ namespace uv {
std::string cwd();
-class thread;
class rwlock;
class loop;
class async;
diff --git a/include/mbgl/util/uv_detail.hpp b/include/mbgl/util/uv_detail.hpp
index 055993db3e..99f5edc145 100644
--- a/include/mbgl/util/uv_detail.hpp
+++ b/include/mbgl/util/uv_detail.hpp
@@ -20,30 +20,6 @@ void close(std::unique_ptr<T> ptr) {
});
}
-class thread : public mbgl::util::noncopyable {
-public:
- inline thread(std::function<void ()> fn_)
- : fn(fn_) {
- if (uv_thread_create(&t, thread_cb, this) != 0) {
- throw std::runtime_error("failed to initialize thread");
- }
- }
-
- void join() {
- if (uv_thread_join(&t) != 0) {
- throw std::runtime_error("failed to join thred");
- }
- }
-
-private:
- static void thread_cb(void* data) {
- reinterpret_cast<thread*>(data)->fn();
- }
-
- uv_thread_t t;
- std::function<void ()> fn;
-};
-
class loop : public mbgl::util::noncopyable {
public:
inline loop() {
@@ -109,49 +85,6 @@ private:
std::function<void ()> fn;
};
-class mutex : public mbgl::util::noncopyable {
- friend class cond;
-
-public:
- 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); }
-
-private:
- uv_mutex_t mtx;
-};
-
-class cond : public mbgl::util::noncopyable {
-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 mbgl::util::noncopyable {
-public:
- lock(mutex &mtx_) : mtx(mtx_) { mtx.lock(); }
- ~lock() { mtx.unlock(); }
-
-private:
- mutex &mtx;
-};
-
class rwlock : public mbgl::util::noncopyable {
public:
inline rwlock() {