The util::Thread will call the stop() method of the MapContext's RunLoop which will wait for the pending tasks tied to it to complete. If we have a request that is timeout'ing, this could mean a really long wait. Instead, we now send a cleanup message that will reset all the attributes first (canceling the pending requests) so the the MapContext gets destructed quickly.
24 lines
832 B
C++
24 lines
832 B
C++
#include "../fixtures/util.hpp"
|
|
|
|
#include <mbgl/map/map_data.hpp>
|
|
#include <mbgl/map/map_context.hpp>
|
|
#include <mbgl/platform/default/headless_view.hpp>
|
|
#include <mbgl/platform/default/headless_display.hpp>
|
|
#include <mbgl/storage/default_file_source.hpp>
|
|
#include <mbgl/util/thread.hpp>
|
|
|
|
using namespace mbgl;
|
|
|
|
TEST(MapContext, DoubleStyleLoad) {
|
|
std::shared_ptr<HeadlessDisplay> display = std::make_shared<HeadlessDisplay>();
|
|
HeadlessView view(display, 512, 512, 1);
|
|
DefaultFileSource fileSource(nullptr);
|
|
MapData data(view, MapMode::Continuous);
|
|
|
|
util::Thread<MapContext> context("Map", util::ThreadPriority::Regular, view, fileSource, data);
|
|
|
|
context.invokeSync(&MapContext::setStyleJSON, "", "");
|
|
context.invokeSync(&MapContext::setStyleJSON, "", "");
|
|
context.invokeSync(&MapContext::cleanup);
|
|
}
|