Reduce critical sections size

C++20
elsid 3 years ago
parent a5b078e9a7
commit 563f3f87dd
No known key found for this signature in database
GPG Key ID: B845CB9FEE18AB40

@ -38,8 +38,9 @@ namespace DetourNavigator
return false;
std::vector<TilePosition> tilesPositions;
{
const TilesPositionsRange range = makeTilesPositionsRange(shape.getShape(), transform, mSettings);
const std::lock_guard lock(mMutex);
getTilesPositions(makeTilesPositionsRange(shape.getShape(), transform, mSettings),
getTilesPositions(range,
[&] (const TilePosition& tilePosition)
{
if (addTile(id, shape, transform, areaType, tilePosition, mTiles))

@ -38,7 +38,6 @@ namespace DetourNavigator
bool changed = false;
std::vector<TilePosition> newTiles;
{
const std::lock_guard lock(mMutex);
const auto onTilePosition = [&] (const TilePosition& tilePosition)
{
if (std::binary_search(currentTiles.begin(), currentTiles.end(), tilePosition))
@ -57,7 +56,9 @@ namespace DetourNavigator
changed = true;
}
};
getTilesPositions(makeTilesPositionsRange(shape.getShape(), transform, mSettings), onTilePosition);
const TilesPositionsRange range = makeTilesPositionsRange(shape.getShape(), transform, mSettings);
const std::lock_guard lock(mMutex);
getTilesPositions(range, onTilePosition);
std::sort(newTiles.begin(), newTiles.end());
for (const auto& tile : currentTiles)
{

Loading…
Cancel
Save