#ifndef MBGL_UTIL_WORKER #define MBGL_UTIL_WORKER #include #include #include #include namespace mbgl { class Worker : public mbgl::util::noncopyable { public: using Fn = std::function; Worker(std::size_t count); ~Worker(); // Request work be done on a thread pool. The optional after callback is // executed on the invoking thread, which must have a run loop, after the // work is complete. // // The return value represents the request to perform the work asynchronously. // Its destructor guarantees that the work is either cancelled and will never // execute, or has finished executing. In other words, the WorkRequest is // guaranteed to outlive any references held by the work function. WorkRequest send(Fn work, Fn after); private: class Impl; std::vector>> threads; std::size_t current = 0; }; } #endif