-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCThumbnailsLoaderThread.cpp
More file actions
88 lines (79 loc) · 2.38 KB
/
CThumbnailsLoaderThread.cpp
File metadata and controls
88 lines (79 loc) · 2.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#include "CThumbnailsLoaderThread.h"
#include "CThumbnailWidget.h"
#include <QDebug>
CThumbnailsLoaderThread::CThumbnailsLoaderThread():
m_pThumbnailList(new QList<CThumbnailWidget*>()),
m_pMutex(new QMutex()),
m_pWriteList(new QWaitCondition()),
m_pReadList(new QWaitCondition())
{
}
void CThumbnailsLoaderThread::run() {
while (true)
{
m_pMutex->lock();
while (m_pThumbnailList->isEmpty())
{
m_pReadList->wait(m_pMutex);
}
m_pThumbnailList->first()->UpdateThumbnail();
m_pThumbnailList->pop_front();
m_pMutex->unlock();
}
// QMutexLocker lock(m_pMutex);
// m_pThumbnailList->first()->UpdateThumbnail();
// m_pThumbnailList->pop_front();
// QList<CThumbnailWidget*>::iterator i;
// for (i = m_pThumbnailList->begin(); i != m_pThumbnailList->end(); ++i)
// {
// if (*i)
// {
// (*i)->UpdateThumbnail();
// }
// }
}
void CThumbnailsLoaderThread::SetThumbnailList(QList<CThumbnailWidget*>* a_pThumbnailList)
{
m_pMutex->lock();
m_pThumbnailList = new QList<CThumbnailWidget*>(*a_pThumbnailList);
m_pMutex->unlock();
m_pReadList->wakeOne();
}
void CThumbnailsLoaderThread::AddThumbnailList(QList<CThumbnailWidget*>* a_pThumbnailList)
{
m_pMutex->lock();
m_pThumbnailList = new QList<CThumbnailWidget*>(*m_pThumbnailList + *a_pThumbnailList);
m_pMutex->unlock();
m_pReadList->wakeOne();
}
void CThumbnailsLoaderThread::AddThumbnail(CThumbnailWidget *a_pThumbnail)
{
m_pMutex->lock();
m_pThumbnailList->push_back(a_pThumbnail);
m_pMutex->unlock();
m_pReadList->wakeOne();
}
void CThumbnailsLoaderThread::Reset()
{
m_pMutex->lock();
m_pThumbnailList->clear();
m_pMutex->unlock();
}
void CThumbnailsLoaderThread::RemoveThumbnail(CThumbnailWidget *a_pThumbnail)
{
m_pMutex->lock();
m_pThumbnailList->removeAll(a_pThumbnail);
m_pMutex->unlock();
}
//void CThumbnailsLoaderThread::run() {
// std::vector<std::string>::iterator i;
// for (i = m_pThumbnailsID.begin(); i != m_pThumbnailsID.end(); ++i)
// {
// qDebug() << QString::fromStdString(*i);
// emit loadCapture(QString::fromStdString(*i));
// }
//}
//void CThumbnailsLoaderThread::SetThumbnailList(const std::vector<std::string> a_vSceneList)
//{
// m_pThumbnailsID = a_vSceneList;
//}