1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-01-29 14:52:12 +01:00

OP37/GCS Map Lib fixed TilesStillToLoad

git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@813 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
zedamota 2010-06-18 23:57:14 +00:00 committed by zedamota
parent d6332aaffa
commit 9e95646cd1
2 changed files with 29 additions and 5 deletions

View File

@ -44,6 +44,7 @@ namespace internals {
renderOffset=Point(0,0); renderOffset=Point(0,0);
dragPoint=Point(0,0); dragPoint=Point(0,0);
CanDragMap=true; CanDragMap=true;
tilesToload=0;
} }
void Core::run() void Core::run()
{ {
@ -55,7 +56,6 @@ namespace internals {
qDebug()<<"core:run"<<" ID="<<debug; qDebug()<<"core:run"<<" ID="<<debug;
#endif //DEBUG_CORE #endif //DEBUG_CORE
bool last = false; bool last = false;
int stillToGo;
LoadTask task; LoadTask task;
@ -65,8 +65,8 @@ namespace internals {
{ {
task = tileLoadQueue.dequeue(); task = tileLoadQueue.dequeue();
{ {
stillToGo=tileLoadQueue.count();
last = (stillToGo == 0); last = (tileLoadQueue.count() == 0);
#ifdef DEBUG_CORE #ifdef DEBUG_CORE
qDebug()<<"TileLoadQueue: " << tileLoadQueue.count()<<" Point:"<<task.Pos.ToString()<<" ID="<<debug;; qDebug()<<"TileLoadQueue: " << tileLoadQueue.count()<<" Point:"<<task.Pos.ToString()<<" ID="<<debug;;
#endif //DEBUG_CORE #endif //DEBUG_CORE
@ -74,13 +74,19 @@ namespace internals {
} }
} }
MtileLoadQueue.unlock(); MtileLoadQueue.unlock();
if(task.HasValue())
if(loaderLimit.tryAcquire(1,OPMaps::Instance()->Timeout)) if(loaderLimit.tryAcquire(1,OPMaps::Instance()->Timeout))
{ {
MtileToload.lock();
--tilesToload;
MtileToload.unlock();
#ifdef DEBUG_CORE #ifdef DEBUG_CORE
qDebug()<<"loadLimit semaphore aquired "<<loaderLimit.available()<<" ID="<<debug<<" TASK="<<task.Pos.ToString()<<" "<<task.Zoom; qDebug()<<"loadLimit semaphore aquired "<<loaderLimit.available()<<" ID="<<debug<<" TASK="<<task.Pos.ToString()<<" "<<task.Zoom;
#endif //DEBUG_CORE #endif //DEBUG_CORE
if(task.HasValue())
{ {
#ifdef DEBUG_CORE #ifdef DEBUG_CORE
qDebug()<<"task as value, begining get"<<" ID="<<debug;; qDebug()<<"task as value, begining get"<<" ID="<<debug;;
#endif //DEBUG_CORE #endif //DEBUG_CORE
@ -153,7 +159,7 @@ namespace internals {
{ {
Matrix.SetTileAt(task.Pos,t); Matrix.SetTileAt(task.Pos,t);
emit OnNeedInvalidation(); emit OnNeedInvalidation();
emit OnTilesStillToLoad(stillToGo);
#ifdef DEBUG_CORE #ifdef DEBUG_CORE
qDebug()<<"Core::run add tile "<<t->GetPos().ToString()<<" to matrix index "<<task.Pos.ToString()<<" ID="<<debug; qDebug()<<"Core::run add tile "<<t->GetPos().ToString()<<" to matrix index "<<task.Pos.ToString()<<" ID="<<debug;
qDebug()<<"Core::run matrix index "<<task.Pos.ToString()<<" as tile with "<<Matrix.TileAt(task.Pos)->Overlays.count()<<" ID="<<debug; qDebug()<<"Core::run matrix index "<<task.Pos.ToString()<<" as tile with "<<Matrix.TileAt(task.Pos)->Overlays.count()<<" ID="<<debug;
@ -161,6 +167,8 @@ namespace internals {
} }
else else
{ {
// emit OnTilesStillToLoad(tilesToload);
delete t; delete t;
t = 0; t = 0;
} }
@ -199,6 +207,7 @@ namespace internals {
#ifdef DEBUG_CORE #ifdef DEBUG_CORE
qDebug()<<"loaderLimit release:"+loaderLimit.available()<<" ID="<<debug; qDebug()<<"loaderLimit release:"+loaderLimit.available()<<" ID="<<debug;
#endif #endif
emit OnTilesStillToLoad(tilesToload<0? 0:tilesToload);
loaderLimit.release(); loaderLimit.release();
} }
} }
@ -215,6 +224,9 @@ namespace internals {
MtileLoadQueue.lock(); MtileLoadQueue.lock();
tileLoadQueue.clear(); tileLoadQueue.clear();
MtileLoadQueue.unlock(); MtileLoadQueue.unlock();
MtileToload.lock();
tilesToload=0;
MtileToload.unlock();
Matrix.Clear(); Matrix.Clear();
GoToCurrentPositionOnZoom(); GoToCurrentPositionOnZoom();
UpdateBounds(); UpdateBounds();
@ -457,6 +469,9 @@ namespace internals {
tileLoadQueue.clear(); tileLoadQueue.clear();
} }
MtileLoadQueue.unlock(); MtileLoadQueue.unlock();
MtileToload.lock();
tilesToload=0;
MtileToload.unlock();
Matrix.Clear(); Matrix.Clear();
emit OnNeedInvalidation(); emit OnNeedInvalidation();
@ -560,8 +575,12 @@ namespace internals {
MtileLoadQueue.lock(); MtileLoadQueue.lock();
{ {
tileLoadQueue.clear(); tileLoadQueue.clear();
//tilesToload=0;
} }
MtileLoadQueue.unlock(); MtileLoadQueue.unlock();
MtileToload.lock();
tilesToload=0;
MtileToload.unlock();
// ProcessLoadTaskCallback.waitForDone(); // ProcessLoadTaskCallback.waitForDone();
} }
} }
@ -586,6 +605,9 @@ namespace internals {
{ {
if(!tileLoadQueue.contains(task)) if(!tileLoadQueue.contains(task))
{ {
MtileToload.lock();
++tilesToload;
MtileToload.unlock();
tileLoadQueue.enqueue(task); tileLoadQueue.enqueue(task);
#ifdef DEBUG_CORE #ifdef DEBUG_CORE
qDebug()<<"Core::UpdateBounds new Task"<<task.Pos.ToString(); qDebug()<<"Core::UpdateBounds new Task"<<task.Pos.ToString();

View File

@ -250,6 +250,8 @@ private:
QSemaphore loaderLimit; QSemaphore loaderLimit;
QThreadPool ProcessLoadTaskCallback; QThreadPool ProcessLoadTaskCallback;
QMutex MtileToload;
int tilesToload;
protected: protected:
bool started; bool started;