Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [Solved] QProcess and recursive QThread
QtWS25 Last Chance

[Solved] QProcess and recursive QThread

Scheduled Pinned Locked Moved General and Desktop
6 Posts 3 Posters 3.1k Views
  • 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.
  • T Offline
    T Offline
    tucnak
    wrote on last edited by
    #1

    Hi, Qt Developer Network Community!

    I am on some step of developing new "Programming Contest Checking System". So I have to run many executable modules many times.

    I have an idea to use recursive QThread object.

    So I created model:

    Main Program creates QVector with tests and QStack with program's pathes.

    Load it into QThread.

    Recursive calls.

    Main object of thread return result of testing

    Will it do something bad with system? I need an advice.

    1 Reply Last reply
    0
    • L Offline
      L Offline
      lgeyer
      wrote on last edited by
      #2

      I'm not quite sure what the "recursive call" in your case could be - could you provide some pseudo-code or alike?

      Why do you need threads in the first place (the first rule of multithreaded programming is: don't do it)? External processes are asynchronous by nature and QProcess has an ansynchronous interface too.

      If you elaborate your initial problem statement we definitly can give you a more reasonable advice.

      1 Reply Last reply
      0
      • T Offline
        T Offline
        tucnak
        wrote on last edited by
        #3

        Thread run QProcess.

        Thread finish process.

        If !stack.isEmpty(): Thread call itself

        At the end, "parent" thread returns special vector

        1 Reply Last reply
        0
        • T Offline
          T Offline
          tucnak
          wrote on last edited by
          #4

          Thanks for attention.

          1 Reply Last reply
          0
          • G Offline
            G Offline
            goetz
            wrote on last edited by
            #5

            This design looks completely broken to me.

            As you do not start multiple threads, you do not need QThread at all. Just loop through your list. A recursive call is completely unnecessary in all cirumstances.

            Why do you want to do that recursively?
            What do you expect from the usage of QThread?

            http://www.catb.org/~esr/faqs/smart-questions.html

            1 Reply Last reply
            0
            • L Offline
              L Offline
              lgeyer
              wrote on last edited by
              #6

              [quote author="tucnak" date="1320351674"]

              Thread run QProcess.

              Thread finish process.

              [/quote]

              Well, you do not need threads to start external processes at all. A call to QProcess::start() immediately returns and the program runs as a completely independet process which doesn't influence or block yours in any way. If the state of the external process changes (aborted, finished) you are notified via signals.

              There is no need for recursion at all. Just loop through your list as Volker suggested.

              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