Stricter Thread<> interface

Implements a Thread<>::invoke interface that only permits calling
member functions with bound arguments.

Also introduce invokeWithResult, which accepts a callback and invokes
it, passing the result, on the invoking thread's RunLoop. This closes
the loop of two evented threads doing message passing.
This commit is contained in:
John Firebaugh
2015-04-13 16:41:37 -07:00
parent 1066504008
commit 1eaf6b8c18
9 changed files with 237 additions and 137 deletions

View File

@@ -2,7 +2,6 @@
#define MBGL_STORAGE_DEFAULT_SQLITE_CACHE_IMPL
#include <mbgl/storage/sqlite_cache.hpp>
#include <mbgl/util/run_loop.hpp>
namespace mapbox {
namespace sqlite {
@@ -13,15 +12,12 @@ class Statement;
namespace mbgl {
class SQLiteCache::Impl : public util::RunLoop {
friend class util::Thread<SQLiteCache::Impl>;
class SQLiteCache::Impl {
public:
Impl(const std::string &path = ":memory:");
~Impl();
public:
void processGet(const Resource& resource, Callback callback);
std::unique_ptr<Response> processGet(const Resource&);
void processPut(const Resource& resource, std::shared_ptr<const Response> response);
void processRefresh(const Resource& resource, int64_t expires);
@@ -29,7 +25,6 @@ private:
void createDatabase();
void createSchema();
private:
const std::string path;
std::unique_ptr<::mapbox::sqlite::Database> db;
std::unique_ptr<::mapbox::sqlite::Statement> getStmt;