Results 1 to 9 of 9

Thread: QtConcurrent::run() and exit()

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    May 2010
    Posts
    15
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QtConcurrent::run() and exit()

    Great article, thanks. But what about my first question? Is there no way to exit a process in a similar way?

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

    Default Re: QtConcurrent::run() and exit()

    You want to exit the whole process or just the thread?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    May 2010
    Posts
    15
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QtConcurrent::run() and exit()

    Oops. Yeah, whenever I said "process" I meant "thread" :P

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

    Default Re: QtConcurrent::run() and exit()

    Just return from your concurrent function then. You cannot abort a running concurrent function from outside - it could render your application in an unpredictable state. If you want to be able to abort an inprogress operation, you have to use some other approach (i.e. the "solving the problem step by step" one from the article - either in an external thread or in the main thread).
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. #5
    Join Date
    May 2010
    Posts
    15
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QtConcurrent::run() and exit()

    Quote Originally Posted by wysota View Post
    Just return from your concurrent function then.
    It's a multi-branch recursive function, returning to the bottom wouldn't be easy.
    Quote Originally Posted by wysota View Post
    You cannot abort a running concurrent function from outside - it could render your application in an unpredictable state.
    I'm not - I'm trying to abort it from the inside at a safe point in response to a flag being set.

    To sum things up, I just want to be able to call a function from a thread that would make the thread just drop everything and stop messing with my data structures Can I do that?

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

    Default Re: QtConcurrent::run() and exit()

    You can throw exceptions from your function and catch them at the upper-most level and then return from the thread function.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  7. #7
    Join Date
    May 2010
    Posts
    15
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QtConcurrent::run() and exit()

    Good suggestion. Thanks again.

Similar Threads

  1. QtConcurrent, i need advice
    By SABROG in forum Qt Programming
    Replies: 10
    Last Post: 29th December 2009, 19:53
  2. Why is QtConcurrent so slow?
    By ArlexBee-871RBO in forum Qt Programming
    Replies: 10
    Last Post: 29th December 2009, 10:37
  3. qtconcurrent
    By knishaq in forum Qt Programming
    Replies: 4
    Last Post: 15th December 2009, 08:41
  4. QtConcurrent Performance
    By tomf in forum Qt Programming
    Replies: 3
    Last Post: 15th July 2008, 15:41
  5. QtConcurrent
    By Brandybuck in forum An Introduction to QThreads
    Replies: 2
    Last Post: 9th May 2008, 14:10

Tags for this Thread

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.