summaryrefslogtreecommitdiff
path: root/include/mbgl/storage/default/request.hpp
diff options
context:
space:
mode:
authorKonstantin Käfer <mail@kkaefer.com>2015-01-16 14:04:41 +0100
committerKonstantin Käfer <mail@kkaefer.com>2015-02-04 10:46:37 +0100
commitb9bf66e67ed1d0d1b1d3163255cab099a6ba4a95 (patch)
tree93ad6df882442e18d9a9771d4b4f06a0a764a0a9 /include/mbgl/storage/default/request.hpp
parent3bfea8bf30c978173f1ec2fab6f89d6b33afea86 (diff)
downloadqtlocation-mapboxgl-b9bf66e67ed1d0d1b1d3163255cab099a6ba4a95.tar.gz
rewrite storage layer to be independent of the Map's event loop
Diffstat (limited to 'include/mbgl/storage/default/request.hpp')
-rw-r--r--include/mbgl/storage/default/request.hpp46
1 files changed, 46 insertions, 0 deletions
diff --git a/include/mbgl/storage/default/request.hpp b/include/mbgl/storage/default/request.hpp
new file mode 100644
index 0000000000..0ed544093c
--- /dev/null
+++ b/include/mbgl/storage/default/request.hpp
@@ -0,0 +1,46 @@
+#ifndef MBGL_STORAGE_DEFAULT_REQUEST
+#define MBGL_STORAGE_DEFAULT_REQUEST
+
+#include <mbgl/storage/resource.hpp>
+
+#include <mbgl/util/util.hpp>
+#include <mbgl/util/noncopyable.hpp>
+
+#include <functional>
+
+typedef struct uv_async_s uv_async_t;
+typedef struct uv_loop_s uv_loop_t;
+
+namespace mbgl {
+
+class Response;
+
+class Request : private util::noncopyable {
+ MBGL_STORE_THREAD(tid)
+
+public:
+ using Callback = std::function<void(const Response &)>;
+ Request(const Resource &resource, uv_loop_t *loop, Callback callback);
+ ~Request();
+
+public:
+ // May be called from any thread.
+ void notify(const std::shared_ptr<const Response> &response);
+ void destruct();
+
+ // May be called only from the thread the Request was created in.
+ void cancel();
+
+private:
+ uv_async_t *notify_async = nullptr;
+ uv_async_t *destruct_async = nullptr;
+ Callback callback;
+ std::shared_ptr<const Response> response;
+
+public:
+ const Resource resource;
+};
+
+}
+
+#endif