修正一个线程分发BUG,线程在stard()后并不会立即启动,导致线程统计延迟无法正确限制线程数量。
This commit is contained in:
+15
-4
@@ -28,8 +28,8 @@ quint32 ipv4str_to_int(const QString& ipstr)
|
||||
|
||||
void trytry::run()
|
||||
{
|
||||
qDebug() << ipstr<<":"<< ipint;
|
||||
*now_thread_num+=1;
|
||||
//qDebug() << ipstr<<":"<< ipint;
|
||||
|
||||
|
||||
QTcpSocket m_socket;
|
||||
m_socket.connectToHost(ipstr, ipint, QTcpSocket::ReadWrite);
|
||||
@@ -43,6 +43,10 @@ void trytry::run()
|
||||
}
|
||||
m_socket.disconnectFromHost();
|
||||
m_socket.disconnect();
|
||||
|
||||
//msleep(timeout);//test
|
||||
|
||||
|
||||
*now_thread_num-=1;
|
||||
|
||||
*nt_bar+=1;
|
||||
@@ -64,14 +68,20 @@ void dispatch::tray(const QString& ipstr, quint32 ipint)
|
||||
|
||||
if (ipint != 0 && ipstr != "")
|
||||
{
|
||||
//qDebug()<<"thread "<<now_thread_num<<":"<<set_thread_num;
|
||||
while (now_thread_num> set_thread_num);
|
||||
|
||||
//qDebug()<<"thread "<<now_thread_num<<":"<<set_thread_num;
|
||||
while (now_thread_num> set_thread_num)
|
||||
{
|
||||
//qDebug()<<"while "<<now_thread_num<<":"<<set_thread_num;
|
||||
}
|
||||
|
||||
try_telnet=new trytry;
|
||||
try_telnet->ipstr = ipstr;
|
||||
try_telnet->ipint = ipint;
|
||||
try_telnet->timeout = timeout;
|
||||
try_telnet->output_list = output_list;
|
||||
|
||||
|
||||
try_telnet->now_thread_num = &now_thread_num;
|
||||
|
||||
try_telnet->t_bar=&t_bar;
|
||||
@@ -84,6 +94,7 @@ void dispatch::tray(const QString& ipstr, quint32 ipint)
|
||||
//try_telnet->moveToThread(main_thread);
|
||||
try_telnet->start();
|
||||
|
||||
now_thread_num+=1;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user