diff options
author | Thiago Marcos P. Santos <thiago@mapbox.com> | 2015-07-01 08:48:11 +0300 |
---|---|---|
committer | Thiago Marcos P. Santos <thiago@mapbox.com> | 2015-07-06 16:01:59 +0300 |
commit | ec1b4c43fd711b7f4f924a21e8428868d7a5f78d (patch) | |
tree | 7e9c24eb96bf3f36d4d3d8548b31699403247f12 | |
parent | f6b8dd4be9677bae18f3d6e50ee706cc3693b933 (diff) | |
download | qtlocation-mapboxgl-ec1b4c43fd711b7f4f924a21e8428868d7a5f78d.tar.gz |
Do not force uv_loop_t as the first parameter for a threaded object ctor
-rw-r--r-- | platform/default/sqlite_cache.cpp | 2 | ||||
-rw-r--r-- | platform/default/sqlite_cache_impl.hpp | 4 | ||||
-rw-r--r-- | src/mbgl/map/map_context.cpp | 4 | ||||
-rw-r--r-- | src/mbgl/map/map_context.hpp | 4 | ||||
-rw-r--r-- | src/mbgl/storage/default_file_source.cpp | 8 | ||||
-rw-r--r-- | src/mbgl/storage/default_file_source_impl.hpp | 4 | ||||
-rw-r--r-- | src/mbgl/util/thread.hpp | 2 | ||||
-rw-r--r-- | src/mbgl/util/worker.cpp | 2 | ||||
-rw-r--r-- | test/miscellaneous/thread.cpp | 5 | ||||
-rw-r--r-- | test/storage/database.cpp | 14 | ||||
-rw-r--r-- | test/style/mock_file_source.cpp | 4 | ||||
-rw-r--r-- | test/style/resource_loading.cpp | 5 |
12 files changed, 25 insertions, 33 deletions
diff --git a/platform/default/sqlite_cache.cpp b/platform/default/sqlite_cache.cpp index c1b1daf234..775c2a68a1 100644 --- a/platform/default/sqlite_cache.cpp +++ b/platform/default/sqlite_cache.cpp @@ -67,7 +67,7 @@ SQLiteCache::SQLiteCache(const std::string& path_) SQLiteCache::~SQLiteCache() = default; -SQLiteCache::Impl::Impl(uv_loop_t*, const std::string& path_) +SQLiteCache::Impl::Impl(const std::string& path_) : path(path_) { } diff --git a/platform/default/sqlite_cache_impl.hpp b/platform/default/sqlite_cache_impl.hpp index 86c7c07bde..8d90fa8813 100644 --- a/platform/default/sqlite_cache_impl.hpp +++ b/platform/default/sqlite_cache_impl.hpp @@ -3,8 +3,6 @@ #include <mbgl/storage/sqlite_cache.hpp> -typedef struct uv_loop_s uv_loop_t; - namespace mapbox { namespace sqlite { class Database; @@ -16,7 +14,7 @@ namespace mbgl { class SQLiteCache::Impl { public: - Impl(uv_loop_t*, const std::string &path = ":memory:"); + Impl(const std::string &path = ":memory:"); ~Impl(); void get(const Resource&, Callback); diff --git a/src/mbgl/map/map_context.cpp b/src/mbgl/map/map_context.cpp index b4bebb4f6b..f6dba408da 100644 --- a/src/mbgl/map/map_context.cpp +++ b/src/mbgl/map/map_context.cpp @@ -26,11 +26,11 @@ namespace mbgl { -MapContext::MapContext(uv_loop_t* loop, View& view_, FileSource& fileSource, MapData& data_) +MapContext::MapContext(View& view_, FileSource& fileSource, MapData& data_) : view(view_), data(data_), updated(static_cast<UpdateType>(Update::Nothing)), - asyncUpdate(std::make_unique<uv::async>(loop, [this] { update(); })), + asyncUpdate(std::make_unique<uv::async>(util::RunLoop::getLoop(), [this] { update(); })), texturePool(std::make_unique<TexturePool>()) { assert(util::ThreadContext::currentlyOn(util::ThreadType::Map)); diff --git a/src/mbgl/map/map_context.hpp b/src/mbgl/map/map_context.hpp index 141a8ee964..724920b825 100644 --- a/src/mbgl/map/map_context.hpp +++ b/src/mbgl/map/map_context.hpp @@ -10,8 +10,6 @@ #include <vector> -typedef struct uv_loop_s uv_loop_t; - namespace uv { class async; } @@ -30,7 +28,7 @@ struct LatLngBounds; class MapContext : public Style::Observer { public: - MapContext(uv_loop_t*, View&, FileSource&, MapData&); + MapContext(View&, FileSource&, MapData&); ~MapContext(); struct RenderResult { diff --git a/src/mbgl/storage/default_file_source.cpp b/src/mbgl/storage/default_file_source.cpp index 5f6bdcb6ac..a9908c450a 100644 --- a/src/mbgl/storage/default_file_source.cpp +++ b/src/mbgl/storage/default_file_source.cpp @@ -71,12 +71,12 @@ void DefaultFileSource::cancel(Request *req) { // ----- Impl ----- -DefaultFileSource::Impl::Impl(uv_loop_t* loop_, FileCache* cache_, const std::string& root) - : loop(loop_), +DefaultFileSource::Impl::Impl(FileCache* cache_, const std::string& root) + : loop(util::RunLoop::getLoop()), cache(cache_), assetRoot(root.empty() ? platform::assetRoot() : root), - assetContext(AssetContext::createContext(loop_)), - httpContext(HTTPContext::createContext(loop_)) { + assetContext(AssetContext::createContext(loop)), + httpContext(HTTPContext::createContext(loop)) { } DefaultFileRequest* DefaultFileSource::Impl::find(const Resource& resource) { diff --git a/src/mbgl/storage/default_file_source_impl.hpp b/src/mbgl/storage/default_file_source_impl.hpp index 22ca5b6d15..06fe3e39b7 100644 --- a/src/mbgl/storage/default_file_source_impl.hpp +++ b/src/mbgl/storage/default_file_source_impl.hpp @@ -8,8 +8,6 @@ #include <set> #include <unordered_map> -typedef struct uv_loop_s uv_loop_t; - namespace mbgl { class RequestBase; @@ -33,7 +31,7 @@ struct DefaultFileRequest { class DefaultFileSource::Impl { public: - Impl(uv_loop_t*, FileCache*, const std::string& = ""); + Impl(FileCache*, const std::string& = ""); void add(Request*); void cancel(Request*); diff --git a/src/mbgl/util/thread.hpp b/src/mbgl/util/thread.hpp index 88a709cfa6..b6eb48dfb6 100644 --- a/src/mbgl/util/thread.hpp +++ b/src/mbgl/util/thread.hpp @@ -118,7 +118,7 @@ void Thread<Object>::run(ThreadContext context, P&& params, std::index_sequence< RunLoop loop_(l.get()); loop = &loop_; - Object object_(l.get(), std::get<I>(std::forward<P>(params))...); + Object object_(std::get<I>(std::forward<P>(params))...); object = &object_; running.set_value(); diff --git a/src/mbgl/util/worker.cpp b/src/mbgl/util/worker.cpp index 9277dacccf..1ab6d766f4 100644 --- a/src/mbgl/util/worker.cpp +++ b/src/mbgl/util/worker.cpp @@ -14,7 +14,7 @@ namespace mbgl { class Worker::Impl { public: - Impl(uv_loop_t*, FileSource* fs) { + Impl(FileSource* fs) { // FIXME: Workers should not access the FileSource but it // is currently needed because of GlyphsPBF. See #1664. util::ThreadContext::setFileSource(fs); diff --git a/test/miscellaneous/thread.cpp b/test/miscellaneous/thread.cpp index 78e6ffee6b..9d8f6b6327 100644 --- a/test/miscellaneous/thread.cpp +++ b/test/miscellaneous/thread.cpp @@ -7,7 +7,7 @@ using namespace mbgl::util; class TestObject { public: - TestObject(uv_loop_t*, std::thread::id otherTid) + TestObject(std::thread::id otherTid) : tid(std::this_thread::get_id()) { EXPECT_NE(tid, otherTid); } @@ -139,8 +139,7 @@ TEST(Thread, context) { class TestWorker { public: - TestWorker(uv_loop_t*) { - } + TestWorker() = default; void send(std::function<void ()> fn, std::function<void ()> cb) { fn(); diff --git a/test/storage/database.cpp b/test/storage/database.cpp index a7560262fe..b40474c004 100644 --- a/test/storage/database.cpp +++ b/test/storage/database.cpp @@ -13,7 +13,7 @@ TEST_F(Storage, DatabaseDoesNotExist) { Log::setObserver(std::make_unique<FixtureLogObserver>()); - SQLiteCache::Impl cache(nullptr, "test/fixtures/404/cache.db"); + SQLiteCache::Impl cache("test/fixtures/404/cache.db"); cache.get({ Resource::Unknown, "mapbox://test" }, [] (std::unique_ptr<Response> res) { EXPECT_EQ(nullptr, res.get()); @@ -55,7 +55,7 @@ TEST_F(Storage, DatabaseCreate) { Log::setObserver(std::make_unique<FixtureLogObserver>()); - SQLiteCache::Impl cache(nullptr, "test/fixtures/database/cache.db"); + SQLiteCache::Impl cache("test/fixtures/database/cache.db"); cache.get({ Resource::Unknown, "mapbox://test" }, [] (std::unique_ptr<Response> res) { EXPECT_EQ(nullptr, res.get()); @@ -111,7 +111,7 @@ TEST_F(Storage, DatabaseLockedRead) { deleteFile("test/fixtures/database/locked.db"); FileLock guard("test/fixtures/database/locked.db"); - SQLiteCache::Impl cache(nullptr, "test/fixtures/database/locked.db"); + SQLiteCache::Impl cache("test/fixtures/database/locked.db"); { // First request should fail. @@ -153,7 +153,7 @@ TEST_F(Storage, DatabaseLockedWrite) { deleteFile("test/fixtures/database/locked.db"); FileLock guard("test/fixtures/database/locked.db"); - SQLiteCache::Impl cache(nullptr, "test/fixtures/database/locked.db"); + SQLiteCache::Impl cache("test/fixtures/database/locked.db"); { // Adds a file (which should fail). @@ -200,7 +200,7 @@ TEST_F(Storage, DatabaseLockedRefresh) { createDir("test/fixtures/database"); deleteFile("test/fixtures/database/locked.db"); - SQLiteCache::Impl cache(nullptr, "test/fixtures/database/locked.db"); + SQLiteCache::Impl cache("test/fixtures/database/locked.db"); // Then, lock the file and try again. FileLock guard("test/fixtures/database/locked.db"); @@ -248,7 +248,7 @@ TEST_F(Storage, DatabaseDeleted) { createDir("test/fixtures/database"); deleteFile("test/fixtures/database/locked.db"); - SQLiteCache::Impl cache(nullptr, "test/fixtures/database/locked.db"); + SQLiteCache::Impl cache("test/fixtures/database/locked.db"); { // Adds a file. @@ -295,7 +295,7 @@ TEST_F(Storage, DatabaseInvalid) { deleteFile("test/fixtures/database/invalid.db"); writeFile("test/fixtures/database/invalid.db", "this is an invalid file"); - SQLiteCache::Impl cache(nullptr, "test/fixtures/database/invalid.db"); + SQLiteCache::Impl cache("test/fixtures/database/invalid.db"); { // Adds a file. diff --git a/test/style/mock_file_source.cpp b/test/style/mock_file_source.cpp index 6aa735d0ea..6f368bde52 100644 --- a/test/style/mock_file_source.cpp +++ b/test/style/mock_file_source.cpp @@ -17,8 +17,8 @@ namespace mbgl { class MockFileSource::Impl { public: - Impl(uv_loop_t* loop, Type type, const std::string& match) - : type_(type), match_(match), timer_(loop) { + Impl(Type type, const std::string& match) + : type_(type), match_(match), timer_(util::RunLoop::getLoop()) { timer_.start(timeout, timeout, [this] { dispatchPendingRequests(); }); timer_.unref(); } diff --git a/test/style/resource_loading.cpp b/test/style/resource_loading.cpp index f65c9c1f97..fc8905f7bb 100644 --- a/test/style/resource_loading.cpp +++ b/test/style/resource_loading.cpp @@ -20,8 +20,7 @@ namespace { class MockMapContext : public Style::Observer { public: - MockMapContext(uv_loop_t* loop, - View& view, + MockMapContext(View& view, FileSource& fileSource, const std::function<void(std::exception_ptr error)>& callback) : data_(MapMode::Still), @@ -33,7 +32,7 @@ public: transform_.setLatLngZoom({0, 0}, 16); const std::string style = util::read_file("test/fixtures/resources/style.json"); - style_ = std::make_unique<Style>(style, "", loop), + style_ = std::make_unique<Style>(style, "", util::RunLoop::getLoop()); style_->setObserver(this); } |