Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions src/CachedTile.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ struct CachedTile
uint8_t z;
bool valid;
bool busy;
SemaphoreHandle_t mutex;
uint16_t *buffer;

CachedTile()
Expand All @@ -43,18 +42,12 @@ struct CachedTile
z(0),
valid(false),
busy(false),
mutex(xSemaphoreCreateMutex()),
buffer(nullptr)
{
}

~CachedTile()
{
if (mutex)
{
vSemaphoreDelete(mutex);
mutex = nullptr;
}
free();
}

Expand Down
56 changes: 7 additions & 49 deletions src/OpenStreetMap-esp32.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,6 @@ OpenStreetMap::~OpenStreetMap()

freeTilesCache();

if (cacheMutex)
{
vSemaphoreDelete(cacheMutex);
cacheMutex = nullptr;
}

if (pngCore0)
{
pngCore0->~PNG();
Expand Down Expand Up @@ -148,7 +142,6 @@ CachedTile *OpenStreetMap::findUnusedTile(const tileList &requiredTiles, uint8_t
{
for (auto &tile : tilesCache)
{
ScopedMutex lock(tile.mutex);
if (tile.busy)
continue;

Expand Down Expand Up @@ -253,10 +246,8 @@ void OpenStreetMap::updateCache(const tileList &requiredTiles, uint8_t zoom)
delay(1);

for (const TileJob &job : jobs)
{
ScopedMutex _(job.tile->mutex);
job.tile->busy = false;
}

log_i("Cache updated in %lu ms", millis() - startMS);
}
}
Expand Down Expand Up @@ -317,17 +308,6 @@ bool OpenStreetMap::composeMap(LGFX_Sprite &mapSprite, const tileList &requiredT

bool OpenStreetMap::fetchMap(LGFX_Sprite &mapSprite, double longitude, double latitude, uint8_t zoom)
{
if (!cacheMutex)
{
cacheMutex = xSemaphoreCreateBinary();
if (!cacheMutex)
{
log_e("could not init cache mutex");
return false;
}
xSemaphoreGive(cacheMutex);
}

if (!tasksStarted && !startTileWorkerTasks())
{
log_e("Failed to start tile worker(s)");
Expand Down Expand Up @@ -533,36 +513,14 @@ void OpenStreetMap::tileFetcherTask(void *param)
while (true)
{
TileJob job;
unsigned long startMS;
{
ScopedMutex lock(osm->cacheMutex);
BaseType_t received = xQueueReceive(osm->jobQueue, &job, portMAX_DELAY);
startMS = millis();

if (received != pdTRUE)
continue;

if (job.z == 255)
break;
xQueueReceive(osm->jobQueue, &job, portMAX_DELAY);
const unsigned long startMS = millis();

if (!job.tile)
continue;
if (job.z == 255)
break;

{
ScopedMutex lock(job.tile->mutex);
if (job.tile->valid &&
job.tile->x == job.x &&
job.tile->y == job.y &&
job.tile->z == job.z)
{
continue;
}

job.tile->x = job.x;
job.tile->y = job.y;
job.tile->z = job.z;
}
}
if (!job.tile)
continue;

String result;
if (!osm->fetchTile(*job.tile, job.x, job.y, job.z, result))
Expand Down
2 changes: 0 additions & 2 deletions src/OpenStreetMap-esp32.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
#include <PNGdec.h>

#include "CachedTile.hpp"
#include "ScopedMutex.hpp"
#include "TileJob.hpp"
#include "MemoryBuffer.hpp"
#include "HTTPClientRAII.hpp"
Expand Down Expand Up @@ -85,7 +84,6 @@ class OpenStreetMap
bool fetchMap(LGFX_Sprite &sprite, double longitude, double latitude, uint8_t zoom);

private:
SemaphoreHandle_t cacheMutex = nullptr;
std::vector<CachedTile> tilesCache;
static inline thread_local OpenStreetMap *currentInstance = nullptr;
static inline thread_local uint16_t *currentTileBuffer = nullptr;
Expand Down
52 changes: 0 additions & 52 deletions src/ScopedMutex.hpp

This file was deleted.