projects
/
qmemory
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Inserita la QwaitCondition
[qmemory]
/
testThread.cpp
diff --git
a/testThread.cpp
b/testThread.cpp
index
fcdf34a
..
e3087e1
100644
(file)
--- a/
testThread.cpp
+++ b/
testThread.cpp
@@
-5,7
+5,7
@@
#include <QDateTime>
TestThread::TestThread(QObject *parent):QThread(parent){
colore=0;
#include <QDateTime>
TestThread::TestThread(QObject *parent):QThread(parent){
colore=0;
- attendiInputUtente=false;
+
index=0;
_score=0;
index=0;
_score=0;
@@
-18,7
+18,7
@@
TestThread::~TestThread(){
void TestThread::run(){
sleep(1);
while(true){
void TestThread::run(){
sleep(1);
while(true){
-
+ mutex.lock();
qsrand(QDateTime::currentDateTime().toTime_t());
sequenza.append(qrand()%9);
int i=0;
qsrand(QDateTime::currentDateTime().toTime_t());
sequenza.append(qrand()%9);
int i=0;
@@
-35,12
+35,11
@@
void TestThread::run(){
i++;
}
i=0;
i++;
}
i=0;
- attendiInputUtente=true;
emit enableInterface();
emit enableInterface();
+ attendiInputUtente.wait(&mutex);
+
+ mutex.unlock();
- while(attendiInputUtente){
- msleep(1);
- }
}
}
@@
-48,7
+47,7
@@
void TestThread::run(){
void TestThread::updateCaption(int inputUser){
void TestThread::updateCaption(int inputUser){
- if(attendiInputUtente){
+
if(sequenza.at(index)==inputUser)
{
if(sequenza.at(index)==inputUser)
{
@@
-57,7
+56,7
@@
void TestThread::updateCaption(int inputUser){
emit score(_score);
if(index==sequenza.size()){
sleep(1);
emit score(_score);
if(index==sequenza.size()){
sleep(1);
- attendiInputUtente=false;
+ attendiInputUtente.wakeAll();
index=0;
}
}
index=0;
}
}
@@
-66,14
+65,14
@@
void TestThread::updateCaption(int inputUser){
_score=0;
sequenza.clear();
index=0;
_score=0;
sequenza.clear();
index=0;
- attendiInputUtente=true;
+ attendiInputUtente.wakeAll();
}
}
- }
+
}
void TestThread::genera()
{
}
void TestThread::genera()
{
- attendiInputUtente=false;
+ attendiInputUtente.wakeAll();
}
}