Re: consuming thread usage.
You can not use threads at all. The GUI thread is enough to do all the tasks.
Re: consuming thread usage.
Is you question about how to avoid threads?
Re: consuming thread usage.
Quote:
Originally Posted by
wysota
You can not use threads at all. The GUI thread is enough to do all the tasks.
first thanks for the reply wysota :)
but how i can receive two different data at a same time in a loop .. from server one and two synchronously ... and display those two datas in a table ..
Quote:
Originally Posted by
Santosh Reddy
Is you question about how to avoid threads?
Thanks for the reply reddy ..
yes ..
i want to reduce the thread usage ...
Re: consuming thread usage.
Quote:
Originally Posted by
wagmare
but how i can receive two different data at a same time in a loop .. from server one and two synchronously ... and display those two datas in a table ..
Use signals and slots. You don't need any loops. When one socket signals it has data ready, read it, store it, check if the other socket already received the data you need and if not then return. Do the same for the other socket. If both sockets already received their data, emit a signal that both are ready and in a slot connected to that signal read the stored data and process it. The latter can be done in an external thread (e.g. using QtConcurrent::run()) if processing is computation intensive.
Re: consuming thread usage.
Quote:
The latter can be done in an external thread (e.g. using QtConcurrent::run()) if processing is computation intensive
Thx wysota ..
yes .. the computation is intense ..
Can u explain me why i should go for QConcurrent ..specifically ..and not normal QThread::run() ..?
Re: consuming thread usage.
There are several reasons. If the computation can be enclosed in a single function then using Qt Concurrent is like calling that single function where you can pass arguments directly and obtain a deferred result through the use of QFuture. With QFutureWatcher you can be notified when the computation is complete. Furthermore Qt Concurrent will spawn only as many threads as there are cores available which allows to handle a situation where data bursts in faster than it can be processed. With a regular QThread You would have to either spawna a new thread for each incoming data which is a straight way to DOS or you would have to queue requests and synchronise the thread. In short if you can use Qt Concurrent, it is usually easier than implementing your own thread.
Re: consuming thread usage.
Well explained ... thank you Wysota ..