Provide Thread objects with access to loop
This commit is contained in:
@@ -67,7 +67,7 @@ SQLiteCache::SQLiteCache(const std::string& path_)
|
||||
|
||||
SQLiteCache::~SQLiteCache() = default;
|
||||
|
||||
SQLiteCache::Impl::Impl(const std::string& path_)
|
||||
SQLiteCache::Impl::Impl(uv_loop_t*, const std::string& path_)
|
||||
: path(path_) {
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
|
||||
#include <mbgl/storage/sqlite_cache.hpp>
|
||||
|
||||
typedef struct uv_loop_s uv_loop_t;
|
||||
|
||||
namespace mapbox {
|
||||
namespace sqlite {
|
||||
class Database;
|
||||
@@ -14,7 +16,7 @@ namespace mbgl {
|
||||
|
||||
class SQLiteCache::Impl {
|
||||
public:
|
||||
Impl(const std::string &path = ":memory:");
|
||||
Impl(uv_loop_t*, const std::string &path = ":memory:");
|
||||
~Impl();
|
||||
|
||||
std::unique_ptr<Response> get(const Resource&);
|
||||
|
||||
@@ -61,7 +61,7 @@ void DefaultFileSource::cancel(Request *req) {
|
||||
|
||||
// ----- Impl -----
|
||||
|
||||
DefaultFileSource::Impl::Impl(FileCache* cache_, const std::string& root)
|
||||
DefaultFileSource::Impl::Impl(uv_loop_t*, FileCache* cache_, const std::string& root)
|
||||
: cache(cache_), assetRoot(root.empty() ? platform::assetRoot() : root) {
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
#include <set>
|
||||
#include <unordered_map>
|
||||
|
||||
typedef struct uv_loop_s uv_loop_t;
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
class RequestBase;
|
||||
@@ -22,7 +24,7 @@ struct DefaultFileRequest {
|
||||
|
||||
class DefaultFileSource::Impl {
|
||||
public:
|
||||
Impl(FileCache*, const std::string& = "");
|
||||
Impl(uv_loop_t*, FileCache*, const std::string& = "");
|
||||
|
||||
void add(Request*, uv_loop_t*);
|
||||
void cancel(Request*);
|
||||
|
||||
@@ -96,12 +96,12 @@ Thread<Object>::Thread(const std::string& name, Args&&... args) {
|
||||
template <class Object>
|
||||
template <typename P, std::size_t... I>
|
||||
void Thread<Object>::run(P&& params, index_sequence<I...>) {
|
||||
Object object_(std::get<I>(std::forward<P>(params))...);
|
||||
object = &object_;
|
||||
|
||||
RunLoop loop_;
|
||||
loop = &loop_;
|
||||
|
||||
Object object_(loop_.get(), std::get<I>(std::forward<P>(params))...);
|
||||
object = &object_;
|
||||
|
||||
running.set_value();
|
||||
loop_.run();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user