Results 1 to 14 of 14

Thread: QThread - parallel

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QThread - parallel

    You can't use a non-static member function from another class. It either has to be static or can't be a member function. What is allowed and what is not is described in Qt Concurrent docs.

  2. #2
    Join Date
    Dec 2009
    Posts
    26
    Thanks
    2
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QThread - parallel

    Got it...

    Took me a while to get that EVERYTHING the QtConcurrent thread uses has to be static.

    Just having a bit of trouble with QFutureWatcher and QtConcurrent. Sometime the app crashes after about 20 files, other times it runs fine, but 'locks' the computer as all 8 cores are running at 100%...

  3. #3
    Join Date
    Oct 2006
    Posts
    279
    Thanks
    6
    Thanked 40 Times in 39 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QThread - parallel

    You can use
    Qt Code:
    1. QThreadPool::globalInstance->setMaxThreadCount()
    To copy to clipboard, switch view to plain text mode 
    to limit the number of threads.
    And if your application still is crashing, you are probably still accessing a shared variable in an unsafe way. I'm thinking of myList and allFiles.
    It sounds like QtConcurrent::mappedReduced could be a candidate for you.

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QThread - parallel

    What exactly does your thread method do? Is there a chance you could post the code here?

  5. #5
    Join Date
    Mar 2008
    Location
    Kraków, Poland
    Posts
    1,540
    Thanked 284 Times in 279 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QThread - parallel

    Quote Originally Posted by sgrant327 View Post
    Got it...

    Took me a while to get that EVERYTHING the QtConcurrent thread uses has to be static.

    Just having a bit of trouble with QFutureWatcher and QtConcurrent. Sometime the app crashes after about 20 files, other times it runs fine, but 'locks' the computer as all 8 cores are running at 100%...
    Because as is writen in documentation Programs written with QtConcurrent automatically adjust the number of threads used according to the number of processor cores available. So they consume 100% available cores.
    Your first idea with ThreadManager and WorkerThread is good. You must only create slot in ThreadManager and connect to them signal QThread::finished(). In this slot start worker with next file.

Similar Threads

  1. Progress Bar set value inside OpenMP parallel for
    By lixo1 in forum Qt Programming
    Replies: 2
    Last Post: 18th February 2010, 19:51
  2. Replies: 1
    Last Post: 6th February 2010, 09:54
  3. Combining sequential and parallel animation
    By mirelon in forum Qt Programming
    Replies: 0
    Last Post: 22nd January 2010, 15:28
  4. Parallel Interface
    By r00tz in forum Qt Programming
    Replies: 31
    Last Post: 19th November 2007, 12:50
  5. Parallel and serial I/O
    By Roberto in forum Qt Programming
    Replies: 3
    Last Post: 10th October 2007, 11:53

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.