But I need to synchronise all the result at the end so I am just waiting till all the threads finished their computations.. any other way to do it or wait without blocking main thread.
But I need to synchronise all the result at the end so I am just waiting till all the threads finished their computations.. any other way to do it or wait without blocking main thread.
Thanks :-)
QFutureWatcher can be used to be notified about a QFuture's completion.
Cheers,
_
prasad_N (28th June 2015)
Thanks. What about canceling these threads, is there away to stop this threads in middle once started ??
Thanks :-)
Not without cooperation of the threads.
The threads need to check for a exit/cancel condition and then cease doing their work.
Maybe you can split the tasks in a series of subtasks and then peform such a check between each step.
Cheers,
_
I can not do it as series of action. The reason i switched to threading is I need to decrease the reading time as much as posible.
Thanks :-)
So you can split it into 5 units of work an no further?
What are those 5 tasks?
Cheers,
_
If suppose I need to read 5 lak rows of data from DB, I am starting 5 threads so that each thread read 1 lak rows, at the end I will merge the result.
The thing is that reading records is from third party function so I do not have control over it(I don't know what is happening inside, how much time will take, I cant not put any bool variable inside it to stop at particular condition ...).
Thanks :-)
So the third party API only allows you to read 1 lak rows, no smaller amount?
I.e. you can't read 50 times 0.1 lak rows?
Cheers,
_
I can read any number, just I need to pass boundaries (start row & end row Indexes).
I can, But what is the use of this approach reading 50 times 0.1 lak rows? (Sorry I may not get your logic)I.e. you can't read 50 times 0.1 lak rows?
Note: We did some experiment and find out that more that 8 threads are slowing down the performance on my machines.
So we are running max 8 threads to to read entire data.
Thanks :-)
Then you can split the work into smaller steps, which you said you could not (comment #7)
Smaller units of work take less time, waiting for such a smaller amount of time on cancel makes the program react to cancel faster.
I already thought that 5 threads are pretty optimistic, but I am not suggesting increasing the number of threads at all.
Cheers,
_
yes, it could have been I don't want instead I cann't :-)
I will try this and get back with the result, I need to check how much time it will take to read entire DB (My main aim is to minimize reading time).
I am working on SLES11 server(high end machine), more that 5 threads might works in my case.
Thanks :-)
Bookmarks