1#include "RasterSourceSubscription.h"
3Cogs::RasterSourceSubscription::RasterSourceSubscription(RasterSourceSubscription && other)
5 std::lock_guard<std::mutex> lock(other.responseMutex);
7 std::swap(rasterSource, other.rasterSource);
8 std::swap(responses, other.responses);
11void Cogs::RasterSourceSubscription::setup(RasterSourcePtr source)
13 assert(!rasterSource &&
"Raster source already setup.");
15 std::lock_guard<std::mutex> lock(source->subscriberMutex);
17 source->addSubscriber(
this);
19 rasterSource = source;
22void Cogs::RasterSourceSubscription::teardown()
25 std::lock_guard<std::mutex> lock(rasterSource->subscriberMutex);
27 rasterSource->removeSubscriber(
this);
33void Cogs::RasterSourceSubscription::postResponse(
const TileLoadResponse & response)
35 std::lock_guard<std::mutex> lock(responseMutex);
37 responses.push_back(response);
40void Cogs::RasterSourceSubscription::getResponses(std::vector<TileLoadResponse> & results,
size_t maxResponses)
42 std::lock_guard<std::mutex> lock(responseMutex);
44 if (responses.size() < maxResponses) {
45 std::swap(responses, results);
47 results.reserve(maxResponses);
49 auto i = maxResponses;
51 results.push_back(responses.back());