[Solved] QProcess and recursive QThread



  • 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.



  • 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.



  • Thread run QProcess.

    Thread finish process.

    If !stack.isEmpty(): Thread call itself

    At the end, "parent" thread returns special vector



  • Thanks for attention.



  • 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?



  • [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.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.