We're now reparsing tiles when they expire. We're also swapping out buckets atomically to avoid flickering data; i.e. we're displaying the old data as long as we don't have a new parsed bucket for that layer yet. The parsed buckets now live in the *TileData objects rather than in the TileWorker; only partially parsed == pending buckets will remain in the TileWorker. Once they're parsed, they're moved to the *TileData object.
64 lines
2.2 KiB
C++
64 lines
2.2 KiB
C++
#ifndef MBGL_UTIL_WORKER
|
|
#define MBGL_UTIL_WORKER
|
|
|
|
#include <mbgl/util/noncopyable.hpp>
|
|
#include <mbgl/util/thread.hpp>
|
|
#include <mbgl/map/tile_worker.hpp>
|
|
|
|
#include <functional>
|
|
#include <memory>
|
|
|
|
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<WorkRequest>;
|
|
|
|
Request parseRasterTile(std::unique_ptr<RasterBucket> bucket,
|
|
std::shared_ptr<const std::string> data,
|
|
std::function<void(TileParseResult)> callback);
|
|
|
|
Request parseVectorTile(TileWorker&,
|
|
std::shared_ptr<const std::string> data,
|
|
std::function<void(TileParseResult)> callback);
|
|
|
|
Request parsePendingVectorTileLayers(TileWorker&,
|
|
std::function<void(TileParseResult)> callback);
|
|
|
|
Request parseLiveTile(TileWorker&,
|
|
const AnnotationTile&,
|
|
std::function<void(TileParseResult)> callback);
|
|
|
|
Request redoPlacement(TileWorker&,
|
|
const std::unordered_map<std::string, std::unique_ptr<Bucket>>&,
|
|
float angle,
|
|
float pitch,
|
|
bool collisionDebug,
|
|
std::function<void()> callback);
|
|
|
|
private:
|
|
class Impl;
|
|
std::vector<std::unique_ptr<util::Thread<Impl>>> threads;
|
|
std::size_t current = 0;
|
|
};
|
|
}
|
|
|
|
#endif
|