Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. General talk
  3. Brainstorm
  4. Multi Threading, pause and resume?
Forum Updated to NodeBB v4.3 + New Features

Multi Threading, pause and resume?

Scheduled Pinned Locked Moved Brainstorm
2 Posts 2 Posters 4.2k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    Jeroi
    wrote on last edited by
    #1

    Since I don't seem to find proper knowledge either on google or in IRC I tought to start this discussion in very interesting topic. Since we all want threading when doing paraller work. But what about threads that takes long time. Some time you want to pause your thread to watch HD movie or some similar case.

    I first taught QRunnable. I subclassed it and tought well I can have signal and slots to control one boolean variable and my worker checks that boolean in every loop that is it paused then start somekind of eternal loop.

    How ever further more studied I became aware that signals and slots are not available with QRunnable so I looked about QThread. And here is atm the situation.

    I have this first suggestion code for my worker class atm: http://stackoverflow.com/questions/9075837/pause-and-resume-a-qthread

    Since one guy over Qt irc channel told me a crazy if I try using QMutex and QWaitCondition to cause pause state and I started to believe that the crazyness might be thing with QWaitCondition::resumeAll() that might interfere another threads going aswell. This even tho QWaitCondition is privately announced for the worker thread.

    So I searched another methods and it seams QtConcurrent support signals and slot somewhat and has pause and resume built in it looks nice, but don't find any good example yet for it.

    So could someone teach me how to to multitasking with correct method to pause and resume?

    1 Reply Last reply
    0
    • JKSHJ Offline
      JKSHJ Offline
      JKSH
      Moderators
      wrote on last edited by
      #2

      Hi,

      It really depends on what you want to do in the other thread, and how you've structured your program.

      I recommend you start by reading "Multithreading Technologies in Qt":http://doc-snapshot.qt-project.org/qt5-release/threads-technologies.html -- it compares all the different ways to use threads in Qt.

      If your program can use the map/filter/reduce pattern, Qt Concurrent provides pause/resume functionality.

      [quote author="Jeroi" date="1400188871"]Since I don't seem to find proper knowledge either on google or in IRC[/quote]Did you check Qt's official documentation?

      • http://qt-project.org/doc/qt-5/qtconcurrent.html
      • http://qt-project.org/doc/qt-5/examples-threadandconcurrent.html

      Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved