QueryQueue is used by QueryWorker to extract the QueryThreadCommand and query with it the database. More...
#include <querythread.h>

Public Member Functions | |
| void | enqueue (const QueryThreadCommand &cmd) |
| QueryThreadCommand | dequeue () |
| bool | contains (const QueryThreadCommand &cmd) const |
QueryQueue is used by QueryWorker to extract the QueryThreadCommand and query with it the database.
There are two prereqisites for the Queue: there should be only one command from a particular sender, and it should follow FIFO principle. Two Qt classes come into mind: QQueue and QSet: for QQueue, a filter should be implemented, for QSet, it doesn't support FIFO so it can hardly be used.
For impl: see http://doc.trolltech.com/qq/qq22-monitors2.html
| bool QueryQueue::contains | ( | const QueryThreadCommand & | cmd | ) | const |
Referenced by Database::execPending().
{
return queue.contains(cmd);
}
| QueryThreadCommand QueryQueue::dequeue | ( | ) |
Referenced by QueryWorker::slotExecute().
{
QMutexLocker lock(&mutex);
if (queue.isEmpty()) return QueryThreadCommand();
return queue.dequeue();
}
| void QueryQueue::enqueue | ( | const QueryThreadCommand & | cmd | ) |
Referenced by Database::execThreaded().
{
QMutexLocker lock(&mutex);
filter(cmd);
queue.enqueue(cmd);
}
1.7.1