Add TaggedScheduler, couple lifetime of tasks and orchestrator (#2398)
This commit is contained in:
@@ -45,48 +45,52 @@ public:
|
||||
|
||||
TEST(TileCache, Smoke) {
|
||||
VectorTileTest test;
|
||||
TileCache cache(Scheduler::GetBackground(), 1);
|
||||
const OverscaledTileID id(0, 0, 0);
|
||||
auto tile = std::make_unique<VectorTileMock>(id, "source", test.tileParameters, test.tileset);
|
||||
{
|
||||
TileCache cache(test.threadPool, 1);
|
||||
const OverscaledTileID id(0, 0, 0);
|
||||
auto tile = std::make_unique<VectorTileMock>(id, "source", test.tileParameters, test.tileset);
|
||||
|
||||
cache.add(id, std::move(tile));
|
||||
EXPECT_TRUE(cache.has(id));
|
||||
cache.clear();
|
||||
EXPECT_FALSE(cache.has(id));
|
||||
cache.add(id, std::move(tile));
|
||||
EXPECT_TRUE(cache.has(id));
|
||||
cache.clear();
|
||||
EXPECT_FALSE(cache.has(id));
|
||||
}
|
||||
}
|
||||
|
||||
TEST(TileCache, Issue15926) {
|
||||
VectorTileTest test;
|
||||
TileCache cache(test.threadPool, 2);
|
||||
const OverscaledTileID id0(0, 0, 0);
|
||||
const OverscaledTileID id1(1, 0, 0);
|
||||
auto tile1 = std::make_unique<VectorTileMock>(id0, "source", test.tileParameters, test.tileset);
|
||||
auto tile2 = std::make_unique<VectorTileMock>(id0, "source", test.tileParameters, test.tileset);
|
||||
auto tile3 = std::make_unique<VectorTileMock>(id1, "source", test.tileParameters, test.tileset);
|
||||
auto tile4 = std::make_unique<VectorTileMock>(id0, "source", test.tileParameters, test.tileset);
|
||||
const auto tile1Id = tile1->uniqueId;
|
||||
{
|
||||
TileCache cache(test.threadPool, 2);
|
||||
const OverscaledTileID id0(0, 0, 0);
|
||||
const OverscaledTileID id1(1, 0, 0);
|
||||
auto tile1 = std::make_unique<VectorTileMock>(id0, "source", test.tileParameters, test.tileset);
|
||||
auto tile2 = std::make_unique<VectorTileMock>(id0, "source", test.tileParameters, test.tileset);
|
||||
auto tile3 = std::make_unique<VectorTileMock>(id1, "source", test.tileParameters, test.tileset);
|
||||
auto tile4 = std::make_unique<VectorTileMock>(id0, "source", test.tileParameters, test.tileset);
|
||||
const auto tile1Id = tile1->uniqueId;
|
||||
|
||||
// add
|
||||
cache.add(id0, std::move(tile1));
|
||||
EXPECT_TRUE(cache.has(id0));
|
||||
// add
|
||||
cache.add(id0, std::move(tile1));
|
||||
EXPECT_TRUE(cache.has(id0));
|
||||
|
||||
// adding a key already present doesn't replace the existing item
|
||||
cache.add(id0, std::move(tile2));
|
||||
EXPECT_EQ(tile1Id, static_cast<VectorTileMock*>(cache.get(id0))->uniqueId);
|
||||
// adding a key already present doesn't replace the existing item
|
||||
cache.add(id0, std::move(tile2));
|
||||
EXPECT_EQ(tile1Id, static_cast<VectorTileMock*>(cache.get(id0))->uniqueId);
|
||||
|
||||
// Evict on add
|
||||
cache.setSize(1);
|
||||
cache.add(id1, std::move(tile3));
|
||||
EXPECT_FALSE(cache.has(id0));
|
||||
EXPECT_TRUE(cache.has(id1));
|
||||
// Evict on add
|
||||
cache.setSize(1);
|
||||
cache.add(id1, std::move(tile3));
|
||||
EXPECT_FALSE(cache.has(id0));
|
||||
EXPECT_TRUE(cache.has(id1));
|
||||
|
||||
// Evict due to size limit change
|
||||
cache.setSize(2);
|
||||
cache.add(id0, std::move(tile4));
|
||||
EXPECT_TRUE(cache.has(id0));
|
||||
EXPECT_TRUE(cache.has(id1));
|
||||
cache.setSize(1);
|
||||
// older item should be evicted
|
||||
EXPECT_TRUE(cache.has(id0));
|
||||
EXPECT_FALSE(cache.has(id1));
|
||||
// Evict due to size limit change
|
||||
cache.setSize(2);
|
||||
cache.add(id0, std::move(tile4));
|
||||
EXPECT_TRUE(cache.has(id0));
|
||||
EXPECT_TRUE(cache.has(id1));
|
||||
cache.setSize(1);
|
||||
// older item should be evicted
|
||||
EXPECT_TRUE(cache.has(id0));
|
||||
EXPECT_FALSE(cache.has(id1));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user