| 1 | #pragma once |
| 2 | |
| 3 | #include <mbgl/util/noncopyable.hpp> |
| 4 | |
| 5 | #include <memory> |
| 6 | |
| 7 | namespace mbgl { |
| 8 | |
| 9 | // A movable type-erasing function wrapper. This allows to store arbitrary invokable |
| 10 | // things (like std::function<>, or the result of a movable-only std::bind()) in the queue. |
| 11 | // Source: http://stackoverflow.com/a/29642072/331379 |
| 12 | class WorkTask : private util::noncopyable { |
| 13 | public: |
| 14 | virtual ~WorkTask() = default; |
| 15 | |
| 16 | virtual void operator()() = 0; |
| 17 | virtual void cancel() = 0; |
| 18 | |
| 19 | template <class Fn, class... Args> |
| 20 | static std::shared_ptr<WorkTask> make(Fn&&, Args&&...); |
| 21 | }; |
| 22 | |
| 23 | } // namespace mbgl |
| 24 | |