Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Q
qgroundcontrol
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Valentin Platzgummer
qgroundcontrol
Commits
1220da39
Commit
1220da39
authored
Mar 19, 2015
by
Don Gagne
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1376 from dogmaphobic/tileWork
Cleaning up Tile Cache Queue
parents
ff6f9101
f82726cf
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
45 additions
and
77 deletions
+45
-77
tilecachequeue.cpp
libs/opmapcontrol/src/core/tilecachequeue.cpp
+41
-71
tilecachequeue.h
libs/opmapcontrol/src/core/tilecachequeue.h
+4
-6
No files found.
libs/opmapcontrol/src/core/tilecachequeue.cpp
View file @
1220da39
...
...
@@ -28,45 +28,39 @@
//#define DEBUG_TILECACHEQUEUE
#ifndef DEBUG_TILECACHEQUEUE
#undef qDebug
#define qDebug QT_NO_QDEBUG_MACRO
#endif
namespace
core
{
TileCacheQueue
::
TileCacheQueue
()
{
}
TileCacheQueue
::~
TileCacheQueue
()
{
// QThread::wait(10000);
quit
();
_waitc
.
wakeAll
();
wait
();
this
->
deleteLater
();
}
void
TileCacheQueue
::
EnqueueCacheTask
(
CacheItemQueue
*
task
)
{
#ifdef DEBUG_TILECACHEQUEUE
qDebug
()
<<
"DB Do I EnqueueCacheTask"
<<
task
->
GetPosition
().
X
()
<<
","
<<
task
->
GetPosition
().
Y
();
#endif //DEBUG_TILECACHEQUEUE
if
(
!
tileCacheQueue
.
contains
(
task
))
{
#ifdef DEBUG_TILECACHEQUEUE
if
(
!
_tileCacheQueue
.
contains
(
task
))
{
qDebug
()
<<
"EnqueueCacheTask"
<<
task
->
GetPosition
().
X
()
<<
","
<<
task
->
GetPosition
().
Y
();
#endif //DEBUG_TILECACHEQUEUE
mutex
.
lock
();
tileCacheQueue
.
enqueue
(
task
);
mutex
.
unlock
();
if
(
this
->
isRunning
())
{
#ifdef DEBUG_TILECACHEQUEUE
_mutex
.
lock
();
_tileCacheQueue
.
enqueue
(
task
);
_mutex
.
unlock
();
if
(
this
->
isRunning
())
{
qDebug
()
<<
"Wake Thread"
;
#endif //DEBUG_TILECACHEQUEUE
//this->start(QThread::NormalPriority);
//waitmutex.lock();
waitc
.
wakeAll
();
//waitmutex.unlock();
}
else
{
#ifdef DEBUG_TILECACHEQUEUE
_waitc
.
wakeAll
();
}
else
{
qDebug
()
<<
"Start Thread"
;
#endif //DEBUG_TILECACHEQUEUE
this
->
start
(
QThread
::
NormalPriority
);
}
}
...
...
@@ -74,59 +68,35 @@ void TileCacheQueue::EnqueueCacheTask(CacheItemQueue *task)
}
void
TileCacheQueue
::
run
()
{
#ifdef DEBUG_TILECACHEQUEUE
qDebug
()
<<
"Cache Engine Start"
;
#endif //DEBUG_TILECACHEQUEUE
while
(
true
)
{
CacheItemQueue
*
task
;
#ifdef DEBUG_TILECACHEQUEUE
qDebug
()
<<
"Cache"
;
#endif //DEBUG_TILECACHEQUEUE
if
(
tileCacheQueue
.
count
()
>
0
)
{
mutex
.
lock
();
task
=
tileCacheQueue
.
dequeue
();
mutex
.
unlock
();
#ifdef DEBUG_TILECACHEQUEUE
qDebug
()
<<
"Cache engine Put:"
<<
task
->
GetPosition
().
X
()
<<
","
<<
task
->
GetPosition
().
Y
();
#endif //DEBUG_TILECACHEQUEUE
Cache
::
Instance
()
->
ImageCache
.
PutImageToCache
(
task
->
GetImg
(),
task
->
GetMapType
(),
task
->
GetPosition
(),
task
->
GetZoom
());
while
(
true
)
{
CacheItemQueue
*
task
=
NULL
;
qDebug
()
<<
"Cache"
;
if
(
_tileCacheQueue
.
count
()
>
0
)
{
_mutex
.
lock
();
task
=
_tileCacheQueue
.
dequeue
();
_mutex
.
unlock
();
Q_ASSERT
(
task
);
qDebug
()
<<
"Cache engine Put:"
<<
task
->
GetPosition
().
X
()
<<
","
<<
task
->
GetPosition
().
Y
();
Cache
*
cache
=
Cache
::
Instance
();
if
(
cache
)
{
cache
->
ImageCache
.
PutImageToCache
(
task
->
GetImg
(),
task
->
GetMapType
(),
task
->
GetPosition
(),
task
->
GetZoom
());
}
usleep
(
44
);
delete
task
;
}
else
{
#ifdef DEBUG_TILECACHEQUEUE
qDebug
()
<<
"Cache engine BEGIN WAIT"
;
#endif //DEBUG_TILECACHEQUEUE
waitmutex
.
lock
();
int
tout
=
4000
;
if
(
!
waitc
.
wait
(
&
waitmutex
,
tout
))
{
waitmutex
.
unlock
();
#ifdef DEBUG_TILECACHEQUEUE
qDebug
()
<<
"Cache Engine TimeOut"
;
#endif //DEBUG_TILECACHEQUEUE
mutex
.
lock
();
if
(
tileCacheQueue
.
count
()
==
0
)
{
mutex
.
unlock
();
break
;
}
mutex
.
unlock
();
}
else
{
qDebug
()
<<
"Cache engine BEGIN WAIT"
;
_waitmutex
.
lock
();
_waitc
.
wait
(
&
_waitmutex
);
qDebug
()
<<
"Cache engine WOKE UP"
;
if
(
!
this
->
isRunning
())
{
_waitmutex
.
unlock
();
break
;
}
#ifdef DEBUG_TILECACHEQUEUE
qDebug
()
<<
"Cache Engine DID NOT TimeOut"
;
#endif //DEBUG_TILECACHEQUEUE
waitmutex
.
unlock
();
_waitmutex
.
unlock
();
}
}
#ifdef DEBUG_TILECACHEQUEUE
qDebug
()
<<
"Cache Engine Stopped"
;
#endif //DEBUG_TILECACHEQUEUE
qDebug
()
<<
"Cache Engine Stopped"
;
}
}
libs/opmapcontrol/src/core/tilecachequeue.h
View file @
1220da39
...
...
@@ -37,7 +37,6 @@
#include "pureimagecache.h"
#include "cache.h"
namespace
core
{
class
TileCacheQueue
:
public
QThread
{
...
...
@@ -47,13 +46,12 @@ namespace core {
~
TileCacheQueue
();
void
EnqueueCacheTask
(
CacheItemQueue
*
task
);
protected:
QQueue
<
CacheItemQueue
*>
tileCacheQueue
;
private:
void
run
();
QMutex
mutex
;
QMutex
waitmutex
;
QWaitCondition
waitc
;
QMutex
_mutex
;
QMutex
_waitmutex
;
QWaitCondition
_waitc
;
QQueue
<
CacheItemQueue
*>
_tileCacheQueue
;
};
}
#endif // TILECACHEQUEUE_H
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment