#ifndef MBGL_UTIL_WORKER #define MBGL_UTIL_WORKER #include #include #include #include #include namespace mbgl { class WorkRequest; class RasterBucket; class AnnotationTile; class Worker : public mbgl::util::noncopyable { public: explicit Worker(std::size_t count); ~Worker(); // Request work be done on a thread pool. Callbacks are 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 function has finished executing, and // that the after function has either finished executing or will not execute. // Together, this means that an object may make a work request with lambdas which // bind references to itself, and if and when those lambdas execute, the references // will still be valid. using Request = std::unique_ptr; Request parseRasterTile(std::unique_ptr bucket, std::shared_ptr data, std::function callback); Request parseVectorTile(TileWorker&, std::shared_ptr data, std::function callback); Request parsePendingVectorTileLayers(TileWorker&, std::function callback); Request parseLiveTile(TileWorker&, const AnnotationTile&, std::function callback); Request redoPlacement(TileWorker&, const std::unordered_map>&, float angle, float pitch, bool collisionDebug, std::function callback); private: class Impl; std::vector>> threads; std::size_t current = 0; }; } #endif