Dear experts,
I'm working in Qt4.7.4 in ubuntu. Does emitting the signal inside a thread is thread safety?
Ex:
{
.....
private:
void sendStatus(int num);
Signals:
void mySignal1();
void mySignal2();
};
void myThread::sendStatus(int num)
{
if(num)
{
emit mySignal1();
}
else
{
emit mySignal2();
}
}
class myThread::public QThread
{
.....
private:
void sendStatus(int num);
Signals:
void mySignal1();
void mySignal2();
};
void myThread::sendStatus(int num)
{
if(num)
{
emit mySignal1();
}
else
{
emit mySignal2();
}
}
To copy to clipboard, switch view to plain text mode
{
public:
........
........
myThread *m;
void myTrans1();
void myTrans2();
};
myClass()
{
m=new myThread();
connect(m,SIGNAL(mySignal1()),this,SLOT(myTrans1());
connect(m,SIGNAL(mySignal2()),this,SLOT(myTrans2());
}
void myClass::myTrans1()
{
//some code
}
void myClass::myTrans2()
{
//some code
}
class myClass::public QWidget
{
public:
........
........
myThread *m;
void myTrans1();
void myTrans2();
};
myClass()
{
m=new myThread();
connect(m,SIGNAL(mySignal1()),this,SLOT(myTrans1());
connect(m,SIGNAL(mySignal2()),this,SLOT(myTrans2());
}
void myClass::myTrans1()
{
//some code
}
void myClass::myTrans2()
{
//some code
}
To copy to clipboard, switch view to plain text mode
is this thread safety?
Thanks,
Bala
Bookmarks