Quote Originally Posted by anda_skoa View Post
You could make ChildA and ChildB implement the QRunnable Interface and then use a QThreadPool with 10 threads.

Or, if you prefer manual thread handling, share a QSemaphore instance between your threads, initialized to 10, and have each thread acquire() it before it runs the operation and release() it when it is done.

No idea about the database thread safety, that might depend on the driver, etc.

Cheers,
_
Thank's for your reply, i have questions about each method if you don't mind:

1 - about QThreadPool, do i have to create 10 different instances for ChildA/ChildB ?!, can you give me a good practice for this method
2 - about QSemaphore, how i manage my QQueue with it ?

let me explain better what i want to do : i have a list of Qurl's and depending on url scheme i instantiate ChildA or ChildB to run an overloaded method that takes the QUrl as parameter (it's always the same method), example :

Qt Code:
  1. QQueue<QUrl> queue;
  2. foreach (QUrl url, urlsList){
  3. queue.enqueue(url);
  4. }
  5. while (!queue.isEmpty()){
  6. QUrl url = queue.dequeue();
  7. if(url.scheme() == ...){
  8. Parent * p = new ChildA;
  9. p.DoSomething(url);
  10. }
  11. else if (url.scheme() == ...){
  12. Parent * p = new ChildB;
  13. p.DoSomething(url);
  14. }
  15. }
To copy to clipboard, switch view to plain text mode 

that means that i have to wait DoSomething(url) finish to treat the next url, what i want is doing this 10 times at the same time (treating 10 url's at the same time whatever the scheme) !

sorry for my stupid questions, i'm a new bee


Quote Originally Posted by Lesiok View Post
From Qt doc : A connection can only be used from within the thread that created it. Moving connections between threads or creating queries from a different thread is not supported.
Thank's for your reply, do you mean by that the QSqlDatabse ?


Thank's eveyone
Cheers