Skip to content

Commit

Permalink
Merge pull request #36 from PropellerAero/threading-fix
Browse files Browse the repository at this point in the history
Thread mutex on GDALTiler constructor
  • Loading branch information
homme authored Jun 22, 2016
2 parents b0f8d8b + 5a51807 commit 8e0cbfd
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/GDALTiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include <cmath> // std::abs
#include <algorithm> // std::minmax
#include <string.h> // strlen
#include <mutex>

#include "gdal_priv.h"
#include "gdalwarper.h"
Expand All @@ -39,6 +40,11 @@ GDALTiler::GDALTiler(GDALDataset *poDataset, const Grid &grid, const TilerOption
poDataset(poDataset),
options(options)
{

// Transformed bounds can give slightly different results on different threads unless mutexed
static std::mutex mutex;
std::lock_guard<std::mutex> lock(mutex);

// if the dataset is set we need to initialise the tile bounds and raster
// resolution from it.
if (poDataset != NULL) {
Expand Down

0 comments on commit 8e0cbfd

Please sign in to comment.