#ifndef MBGL_UTIL_WORKER #define MBGL_UTIL_WORKER #include #include #include #include #include namespace mbgl { class WorkRequest; class RasterBucket; class GeometryTileLoader; using RasterTileParseResult = mapbox::util::variant< std::unique_ptr, // success std::exception_ptr>; // error 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 parseGeometryTile(TileWorker&, std::vector>, std::unique_ptr, PlacementConfig, std::function callback); Request parsePendingGeometryTileLayers(TileWorker&, PlacementConfig config, std::function callback); Request redoPlacement(TileWorker&, const std::unordered_map>&, PlacementConfig config, std::function callback); private: class Impl; std::vector>> threads; std::size_t current = 0; }; } // namespace mbgl #endif