summaryrefslogtreecommitdiff
path: root/include/mbgl/util/work_task.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'include/mbgl/util/work_task.hpp')
-rw-r--r--include/mbgl/util/work_task.hpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/include/mbgl/util/work_task.hpp b/include/mbgl/util/work_task.hpp
new file mode 100644
index 0000000000..2224b211c4
--- /dev/null
+++ b/include/mbgl/util/work_task.hpp
@@ -0,0 +1,21 @@
+#ifndef MBGL_UTIL_WORK_TASK
+#define MBGL_UTIL_WORK_TASK
+
+#include <mbgl/util/noncopyable.hpp>
+
+namespace mbgl {
+
+// A movable type-erasing function wrapper. This allows to store arbitrary invokable
+// things (like std::function<>, or the result of a movable-only std::bind()) in the queue.
+// Source: http://stackoverflow.com/a/29642072/331379
+class WorkTask : private util::noncopyable {
+public:
+ virtual ~WorkTask() = default;
+
+ virtual void operator()() = 0;
+ virtual void cancel() = 0;
+};
+
+}
+
+#endif